Added testing function for ZString.
This commit is contained in:
parent
191899fbb7
commit
a0129273b3
@ -57,6 +57,10 @@ namespace coreutils {
|
|||||||
return ZString();
|
return ZString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZString IMFMessage::getHeaderKeyPairValue(const char *headerKey, const char *key) {
|
||||||
|
return getHeaderKeyPairValue(ZString(headerKey), ZString(key));
|
||||||
|
}
|
||||||
|
|
||||||
ZString IMFMessage::getHeaderKeyPairValue(ZString headerKey, ZString key) {
|
ZString IMFMessage::getHeaderKeyPairValue(ZString headerKey, ZString key) {
|
||||||
ZString value;
|
ZString value;
|
||||||
ZString psource(getHeader(headerKey, false));
|
ZString psource(getHeader(headerKey, false));
|
||||||
|
@ -19,6 +19,7 @@ namespace coreutils {
|
|||||||
void addHeader(const char *key, ZString value);
|
void addHeader(const char *key, ZString value);
|
||||||
|
|
||||||
ZString getHeader(ZString key, bool valueOnly = true);
|
ZString getHeader(ZString key, bool valueOnly = true);
|
||||||
|
ZString getHeaderKeyPairValue(const char *headerKey, const char *key);
|
||||||
ZString getHeaderKeyPairValue(ZString headerKey, ZString key);
|
ZString getHeaderKeyPairValue(ZString headerKey, ZString key);
|
||||||
|
|
||||||
IMFBody * getBody();
|
IMFBody * getBody();
|
||||||
|
@ -44,4 +44,8 @@ namespace coreutils {
|
|||||||
addHeader("Set-Cookie", data);
|
addHeader("Set-Cookie", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMFResponse::setCookie(ZString key, std::string data) {
|
||||||
|
addHeader("Set-Cookie", ZString(data.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ namespace coreutils {
|
|||||||
void setText(ZString text);
|
void setText(ZString text);
|
||||||
|
|
||||||
void setCookie(ZString key, ZString data);
|
void setCookie(ZString key, ZString data);
|
||||||
|
void setCookie(ZString key, std::string data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ZString protocol;
|
ZString protocol;
|
||||||
|
20
ZString.cpp
20
ZString.cpp
@ -36,7 +36,7 @@ namespace coreutils {
|
|||||||
data = zstring.data;
|
data = zstring.data;
|
||||||
length = zstring.length;
|
length = zstring.length;
|
||||||
cursor = zstring.cursor;
|
cursor = zstring.cursor;
|
||||||
// Log(LOG_DEBUG_2) << "ZSrting Copy Constructor: ";
|
// Log(LOG_DEBUG_2) << "ZString Copy Constructor: ";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ZString> &ZString::getList() {
|
std::vector<ZString> &ZString::getList() {
|
||||||
@ -66,7 +66,7 @@ namespace coreutils {
|
|||||||
std::vector<ZString> &ZString::split(ZString &delimiter, size_t maxSize) {
|
std::vector<ZString> &ZString::split(ZString &delimiter, size_t maxSize) {
|
||||||
list.clear();
|
list.clear();
|
||||||
if(length == 0) {
|
if(length == 0) {
|
||||||
list.push_back(ZString((char *)""));
|
list.push_back(ZString(""));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,13 +75,13 @@ namespace coreutils {
|
|||||||
|
|
||||||
while(pos < end) {
|
while(pos < end) {
|
||||||
if(strncmp(pos, delimiter.getData(), delimiter.getLength()) == 0) {
|
if(strncmp(pos, delimiter.getData(), delimiter.getLength()) == 0) {
|
||||||
list.push_back(ZString(cursor, pos - cursor));
|
list.push_back(ZString(cursor, pos - cursor));
|
||||||
cursor = pos + delimiter.getLength();
|
cursor = pos + delimiter.getLength();
|
||||||
pos = cursor;
|
pos = cursor;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.push_back(ZString(cursor, pos - cursor));
|
list.push_back(ZString(cursor, pos - cursor));
|
||||||
cursor = pos;
|
cursor = pos;
|
||||||
@ -128,7 +128,7 @@ namespace coreutils {
|
|||||||
|
|
||||||
bool ZString::equals(ZString &zstring) {
|
bool ZString::equals(ZString &zstring) {
|
||||||
if(zstring.getLength() != getLength())
|
if(zstring.getLength() != getLength())
|
||||||
return false;
|
return false;
|
||||||
return strncmp(data, zstring.getData(), getLength()) == 0;
|
return strncmp(data, zstring.getData(), getLength()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,9 +197,11 @@ namespace coreutils {
|
|||||||
|
|
||||||
void setZString(ZString zstring);
|
void setZString(ZString zstring);
|
||||||
|
|
||||||
|
size_t length;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *data;
|
char *data;
|
||||||
size_t length;
|
// size_t length;
|
||||||
char *cursor;
|
char *cursor;
|
||||||
std::vector<ZString> list;
|
std::vector<ZString> list;
|
||||||
|
|
||||||
|
BIN
testing/zstring_test
Executable file
BIN
testing/zstring_test
Executable file
Binary file not shown.
17
testing/zstring_test.cpp
Normal file
17
testing/zstring_test.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "../ZString.h"
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
coreutils::ZString test("character1111:22222:33333");
|
||||||
|
test.length = 9;
|
||||||
|
|
||||||
|
test.split(":");
|
||||||
|
|
||||||
|
std::cout << test << std::endl;
|
||||||
|
std::cout << test.getLength() << std::endl;
|
||||||
|
|
||||||
|
std::cout << test[0] << std::endl;
|
||||||
|
std::cout << test[1] << std::endl;
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user