Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ippStringBuilderTestCase.cpp

Go to the documentation of this file.
00001 
00002 #include "ippStringBuilderTestCase.h"
00003 
00004 #include "ippdme/ippTag.h"
00005 #include "ippdme/Misc/ippStringBuilder.h"
00006 #define IPP_END_STRING "\r\n"
00007 
00008 
00009 void ippStringBuilderTestCase::test1()
00010 {
00011 
00012   ippStringBuilder builder;
00013   builder.Append("00001 ");
00014   builder.StartFunc("StartSession");
00015   builder.EndFunc();
00016   
00017   std::string t = builder.ToString();
00018 
00019   IPP_UTEST_ASSERT_EQUALS(0,strcmp(t.c_str(),"00001 StartSession()"IPP_END_STRING));
00020 
00021 }
00022 
00023 void ippStringBuilderTestCase::test2()
00024 {
00025 /* 
00026    param X;
00027    param Y;
00028    param Z;
00029    param GoTo;
00030    
00031    builder = GoTo(X(1.10),Y(1.10),Z(12.0));
00032 */
00033 
00034   ippStringBuilder builder;
00035   builder.Append("E0000");
00036   builder.Append(" # ");
00037   builder.StartFunc("GoTo");
00038     builder.AppendFunc("X",1.1);
00039     builder.AppendFunc("Y",2.2000000000001);
00040   builder.EndFunc();
00041   
00042   std::string t = builder.ToString();
00043   IPP_UTEST_ASSERT_EQUALS(t,"E0000 # GoTo(X(1.1), Y(2.2))"IPP_END_STRING);
00044 }
00045 
00046 void ippStringBuilderTestCase::test3()
00047 {
00048 
00049   ippStringBuilder builder;
00050   builder.Append("E0000");
00051   builder.Append(" # ");
00052   builder.AppendFunc("ER",100.);
00053   builder.AppendFunc("Y",1.);  
00054   std::string t = builder.ToString();
00055   IPP_UTEST_ASSERT_EQUALS(t,"E0000 # ER(100.), Y(1.)"IPP_END_STRING);
00056 }
00057 
00058 void ippStringBuilderTestCase::test4()
00059 {
00060   ippStringBuilder builder;
00061   builder.Append("00010 # ");
00062   builder.AppendFunc("DMEVersion","1.3.9");  
00063   std::string t = builder.ToString();
00064   const std::string expected_String="00010 # DMEVersion(\"1.3.9\")"IPP_END_STRING;
00065   IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00066 }
00067 
00068 void ippStringBuilderTestCase::test5()
00069 {
00070 // 00080 # Tool.Alignment(0.8, 0.6, 0.0, 0.0, 0.0, 1.0)
00071   ippStringBuilder builder;
00072   builder.Append("00080 # ");
00073   builder.StartFunc("Tool.Alignment");
00074   builder.AppendParam(0.8);
00075   builder.AppendParam(0.6);
00076   builder.AppendParam(0.0);
00077   builder.AppendParam(0.0);
00078   builder.AppendParam(0.0);
00079   builder.AppendParam(1.0);
00080   builder.EndFunc();
00081   std::string t = builder.ToString();
00082   IPP_UTEST_ASSERT_EQUALS(t,"00080 # Tool.Alignment(0.8, 0.6, 0., 0., 0., 1.)"IPP_END_STRING);
00083 
00084 }
00085 
00086 void ippStringBuilderTestCase::test6()
00087 {
00088   //"E0000 # ChangeTool("MyTool")"
00089   ippStringBuilder builder(ippTag(80,CommandTag),"#");
00090   builder.AppendFunc("ChangeTool","MyTool");
00091   std::string t = builder.ToString();
00092   const std::string expected_String="00080 # ChangeTool(\"MyTool\")"IPP_END_STRING;
00093   IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00094   
00095 }
00096 void ippStringBuilderTestCase::test7()
00097 {
00098   // 00070 ! Error(3, 0509, "00070 GoTo(X(0.34.33))", "Bad Argument")
00099   ippStringBuilder builder(ippTag(70,CommandTag),"!");
00100   builder.StartFunc("Error");
00101   builder.AppendParam(3);
00102   builder.AppendParam(ippErrorNameType(BadArgument));
00103   builder.AppendParam("00070 GoTo(X(0.34.33))");
00104   builder.AppendParam("Bad Argument");
00105   builder.EndFunc();
00106   std::string t = builder.ToString();
00107   const std::string expected_String="00070 ! Error(3, 0509, \"00070 GoTo(X(0.34.33))\", \"Bad Argument\")"IPP_END_STRING;
00108   IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00109 
00110 }
00111 void ippStringBuilderTestCase::test8()
00112 {
00113   ippTag _tag(116,CenterPart);
00114   bool _centered = true;
00115   std::string t = ippStringBuilder(_tag,"#").AppendFunc("CenterPart",(_centered ? 1 : 0)).ToString();
00116   IPP_UTEST_ASSERT_EQUALS(t,"00116 # CenterPart(1)"IPP_END_STRING);
00117 
00118 }
00119 
00120 void ippStringBuilderTestCase::test9()
00121 {
00122   // 00070 ! Hello(Community(1.),Ippdme(2.,3.4))
00123   ippStringBuilder builder(ippTag(70,CommandTag),"!");
00124   builder.StartFunc("Hello");
00125 
00126    builder.AppendFunc("Community",1.);
00127    builder.StartFunc("Ippdme");
00128      builder.AppendParam(2.);
00129      builder.AppendParam(3.);
00130      builder.AppendParam(4.);
00131    builder.EndFunc();
00132   builder.EndFunc();
00133   std::string t = builder.ToString();
00134   const std::string expected_String="00070 ! Hello(Community(1.), Ippdme(2., 3., 4.))"IPP_END_STRING;
00135   IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00136 }

Generated on Wed Nov 8 00:20:09 2006 for IPPDME by  doxygen 1.4.1