summaryrefslogtreecommitdiffstats
path: root/tdeioslave/smtp/test_responseparser.cc
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:02:02 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:02:02 -0600
commitde7e5867a65e0a46f1388e3e50bc7eeddd1aecbf (patch)
treedbb3152c372f8620f9290137d461f3d9f9eba1cb /tdeioslave/smtp/test_responseparser.cc
parent936d3cec490c13f2c5f7dd14f5e364fddaa6da71 (diff)
downloadtdebase-de7e5867a65e0a46f1388e3e50bc7eeddd1aecbf.tar.gz
tdebase-de7e5867a65e0a46f1388e3e50bc7eeddd1aecbf.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdeioslave/smtp/test_responseparser.cc')
-rw-r--r--tdeioslave/smtp/test_responseparser.cc107
1 files changed, 107 insertions, 0 deletions
diff --git a/tdeioslave/smtp/test_responseparser.cc b/tdeioslave/smtp/test_responseparser.cc
new file mode 100644
index 000000000..e251aa291
--- /dev/null
+++ b/tdeioslave/smtp/test_responseparser.cc
@@ -0,0 +1,107 @@
+#include "response.h"
+#include <assert.h>
+
+static const TQCString singleLineResponseCRLF = "250 OK\r\n";
+static const TQCString singleLineResponse = "250 OK";
+
+static const TQCString multiLineResponse[] = {
+ "250-ktown.kde.org\r\n",
+ "250-STARTTLS\r\n",
+ "250-AUTH PLAIN DIGEST-MD5\r\n",
+ "250 PIPELINING\r\n"
+};
+static const unsigned int numMultiLineLines = sizeof multiLineResponse / sizeof *multiLineResponse ;
+
+int main ( int, char** ) {
+
+ KioSMTP::Response r;
+ assert( r.isValid() );
+ assert( r.lines().empty() );
+ assert( r.isWellFormed() );
+ assert( r.code() == 0 );
+ assert( r.isUnknown() );
+ assert( !r.isComplete() );
+ assert( !r.isOk() );
+ r.parseLine( singleLineResponseCRLF.data(),
+ singleLineResponseCRLF.length() );
+ assert( r.isWellFormed() );
+ assert( r.isComplete() );
+ assert( r.isValid() );
+ assert( r.isPositive() );
+ assert( r.isOk() );
+ assert( r.code() == 250 );
+ assert( r.errorCode() == 0 );
+ assert( r.first() == 2 );
+ assert( r.second() == 5 );
+ assert( r.third() == 0 );
+ assert( r.lines().count() == 1 );
+ assert( r.lines().front() == "OK" );
+ r.parseLine( singleLineResponse.data(),
+ singleLineResponse.length() );
+ assert( !r.isValid() );
+ r.clear();
+ assert( r.isValid() );
+ assert( r.lines().empty() );
+
+ r.parseLine( singleLineResponse.data(),
+ singleLineResponse.length() );
+ assert( r.isWellFormed() );
+ assert( r.isComplete() );
+ assert( r.isValid() );
+ assert( r.isPositive() );
+ assert( r.isOk() );
+ assert( r.code() == 250 );
+ assert( r.first() == 2 );
+ assert( r.second() == 5 );
+ assert( r.third() == 0 );
+ assert( r.lines().count() == 1 );
+ assert( r.lines().front() == "OK" );
+ r.parseLine( singleLineResponse.data(),
+ singleLineResponse.length() );
+ assert( !r.isValid() );
+ r.clear();
+ assert( r.isValid() );
+
+ for ( unsigned int i = 0 ; i < numMultiLineLines ; ++i ) {
+ r.parseLine( multiLineResponse[i].data(),
+ multiLineResponse[i].length() );
+ assert( r.isWellFormed() );
+ if ( i < numMultiLineLines-1 )
+ assert( !r.isComplete() );
+ else
+ assert( r.isComplete() );
+ assert( r.isValid() );
+ assert( r.isPositive() );
+ assert( r.code() == 250 );
+ assert( r.first() == 2 );
+ assert( r.second() == 5 );
+ assert( r.third() == 0 );
+ assert( r.lines().count() == i + 1 );
+ }
+ assert( r.lines().back() == "PIPELINING" );
+
+ r.clear();
+ r.parseLine( "230", 3 );
+ assert( r.isValid() );
+ assert( r.isWellFormed() ); // even though it isn't ;-)
+ assert( r.code() == 230 );
+ assert( r.lines().count() == 1 );
+ assert( r.lines().front().isNull() );
+
+ r.clear();
+ r.parseLine( "230\r\n", 5 );
+ assert( r.isValid() );
+ assert( r.isWellFormed() ); // even though it isn't ;-)
+ assert( r.code() == 230 );
+ assert( r.lines().count() == 1 );
+ assert( r.lines().front().isNull() );
+
+ r.clear();
+ r.parseLine( " 23 ok", 6 );
+ assert( !r.isValid() );
+ assert( !r.isWellFormed() );
+
+ return 0;
+}
+
+#include "response.cc"