#include "../common/file.h"
#include "../common/text.h"
+#include "../common/colour.h"
TEST(CommonFunctions, FileTests){
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, SplitPathFilename){
+
+ // Setup the file split.
+
+ string PathFilenameOriginal = "/example/file/yay.txt";
+ string Path = "";
+ string File = "";
+
+ SplitPathFilename(&PathFilenameOriginal, &Path, &File);
+
+ ASSERT_EQ("/example/file/", Path);
+ ASSERT_EQ("yay.txt", File);
+
+ PathFilenameOriginal = "/a/path/with/lots/of/bits/in/andthenthis.html";
+ Path.clear();
+ File.clear();
+
+ SplitPathFilename(&PathFilenameOriginal, &Path, &File);
+
+ ASSERT_EQ("/a/path/with/lots/of/bits/in/", Path);
+ ASSERT_EQ("andthenthis.html", File);
+
+ PathFilenameOriginal = "/one/more/for/a/laugh/hahaha.zip";
+ Path.clear();
+ File.clear();
+
+ SplitPathFilename(&PathFilenameOriginal, &Path, &File);
+
+ ASSERT_EQ("/one/more/for/a/laugh/", Path);
+ ASSERT_EQ("hahaha.zip", File);
+
+}
+
+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);
+
+}
+
+TEST(CommonFunctions, OutputText){
+
+ string InputText1 = "This is an example text.";
+ string OutputText1 = "This is an example text.";
+ string ResultText1 = "";
+
+ string InputText2 = "This is the first sentence. This is the second sentence"
+ ". This is the third sentence. This is the fourth sentence. This "
+ "is the fifth sentence.";
+ string OutputText2 = "This is the first sentence. This is the second sentence"
+ ". This is the third se\n ntence. This is the fourth sentence. This "
+ "is the fifth sentence.";
+ string ResultText2 = "";
+
+ string InputText3 = "This is the first sentence. This is the second sentence"
+ ". This is the third sentence. This is the fourth sentence. This "
+ "is the fifth sentence. This is the sixth sentence. This is the s"
+ "eventh sentence. This is the eighth sentence. This is the ninth "
+ "sentence. This is the tenth sentence.";
+ string OutputText3 = "This is the first sentence. This is the second sentence. This is the third se\n"
+ " ntence. This is the fourth sentence. This is the fifth sentence. This is the\n"
+ " sixth sentence. This is the seventh sentence. This is the eighth sentence. \n"
+ " This is the ninth sentence. This is the tenth sentence.";
+ string ResultText3 = "";
+
+ string InputText4 = "This is the first sentence. This is the second sentence"
+ ". This is the third sentence. This is the fourth sentence. This "
+ "is the fifth sentence. This is the sixth sentence. This is the s"
+ "eventh sentence. This is the eighth sentence. This is the ninth "
+ "sentence. This is the tenth sentence. This is the eleventh sente"
+ "nce. This is the twelfth sentence. This is the thirteenth senten"
+ "ce. This is the fourteenth sentence. This is the fifteenth sente"
+ "nce.";
+ string OutputText4 = "This is the first sentence. This is the second sentence. This is the third se\n"
+ " ntence. This is the fourth sentence. This is the fifth sentence. This is the\n"
+ " sixth sentence. This is the seventh sentence. This is the eighth sentence. \n"
+ " This is the ninth sentence. This is the tenth sentence. This is the eleventh\n"
+ " sentence. This is the twelfth sentence. This is the thirteenth sentence. Th\n"
+ " is is the fourteenth sentence. This is the fifteenth sentence.";
+ string ResultText4 = "";
+
+ string InputText5 = "This is the first sentence. This is the second sentence"
+ ". This is the third sentence. This is the fourth sentence. This "
+ "is the fifth sentence. This is the sixth sentence. This is the s"
+ "eventh sentence. This is the eighth sentence. This is the ninth "
+ "sentence. This is the tenth sentence. This is the eleventh sente"
+ "nce. This is the twelfth sentence. This is the thirteenth senten"
+ "ce. This is the fourteenth sentence. This is the fifteenth sente"
+ "nce. This is the sixteenth sentence. This is the seventeenth sen"
+ "tence. This is the eighteenth sentence. This is the ninteenth se"
+ "ntence. This is the twentieth sentence.";
+ string OutputText5 = "This is the first sentence. This is the second sentence. This is the third se\n"
+ " ntence. This is the fourth sentence. This is the fifth sentence. This is the\n"
+ " sixth sentence. This is the seventh sentence. This is the eighth sentence. \n"
+ " This is the ninth sentence. This is the tenth sentence. This is the eleventh\n"
+ " sentence. This is the twelfth sentence. This is the thirteenth sentence. Th\n"
+ " is is the fourteenth sentence. This is the fifteenth sentence. This is the s\n"
+ " ixteenth sentence. This is the seventeenth sentence. This is the eighteenth \n"
+ " sentence. This is the ninteenth sentence. This is the twentieth sentence.";
+ string ResultText5;
+
+ ResultText1 = OutputText(&InputText1);
+ ResultText2 = OutputText(&InputText2);
+ ResultText3 = OutputText(&InputText3);
+ ResultText4 = OutputText(&InputText4);
+ ResultText5 = OutputText(&InputText5);
+
+ ASSERT_EQ(ResultText1, OutputText1);
+ ASSERT_EQ(ResultText2, OutputText2);
+ ASSERT_EQ(ResultText3, OutputText3);
+ ASSERT_EQ(ResultText4, OutputText4);
+ ASSERT_EQ(ResultText5, OutputText5);
+
}
\ No newline at end of file