Added testing function for ZString.
This commit is contained in:
parent
191899fbb7
commit
a0129273b3
@ -57,6 +57,10 @@ namespace coreutils {
|
||||
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 value;
|
||||
ZString psource(getHeader(headerKey, false));
|
||||
|
@ -19,6 +19,7 @@ namespace coreutils {
|
||||
void addHeader(const char *key, ZString value);
|
||||
|
||||
ZString getHeader(ZString key, bool valueOnly = true);
|
||||
ZString getHeaderKeyPairValue(const char *headerKey, const char *key);
|
||||
ZString getHeaderKeyPairValue(ZString headerKey, ZString key);
|
||||
|
||||
IMFBody * getBody();
|
||||
|
@ -44,4 +44,8 @@ namespace coreutils {
|
||||
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 setCookie(ZString key, ZString data);
|
||||
void setCookie(ZString key, std::string data);
|
||||
|
||||
private:
|
||||
ZString protocol;
|
||||
|
20
ZString.cpp
20
ZString.cpp
@ -36,7 +36,7 @@ namespace coreutils {
|
||||
data = zstring.data;
|
||||
length = zstring.length;
|
||||
cursor = zstring.cursor;
|
||||
// Log(LOG_DEBUG_2) << "ZSrting Copy Constructor: ";
|
||||
// Log(LOG_DEBUG_2) << "ZString Copy Constructor: ";
|
||||
}
|
||||
|
||||
std::vector<ZString> &ZString::getList() {
|
||||
@ -66,7 +66,7 @@ namespace coreutils {
|
||||
std::vector<ZString> &ZString::split(ZString &delimiter, size_t maxSize) {
|
||||
list.clear();
|
||||
if(length == 0) {
|
||||
list.push_back(ZString((char *)""));
|
||||
list.push_back(ZString(""));
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -75,13 +75,13 @@ namespace coreutils {
|
||||
|
||||
while(pos < end) {
|
||||
if(strncmp(pos, delimiter.getData(), delimiter.getLength()) == 0) {
|
||||
list.push_back(ZString(cursor, pos - cursor));
|
||||
cursor = pos + delimiter.getLength();
|
||||
pos = cursor;
|
||||
}
|
||||
else {
|
||||
++pos;
|
||||
}
|
||||
list.push_back(ZString(cursor, pos - cursor));
|
||||
cursor = pos + delimiter.getLength();
|
||||
pos = cursor;
|
||||
}
|
||||
else {
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
list.push_back(ZString(cursor, pos - cursor));
|
||||
cursor = pos;
|
||||
@ -128,7 +128,7 @@ namespace coreutils {
|
||||
|
||||
bool ZString::equals(ZString &zstring) {
|
||||
if(zstring.getLength() != getLength())
|
||||
return false;
|
||||
return false;
|
||||
return strncmp(data, zstring.getData(), getLength()) == 0;
|
||||
}
|
||||
|
||||
|
@ -197,9 +197,11 @@ namespace coreutils {
|
||||
|
||||
void setZString(ZString zstring);
|
||||
|
||||
size_t length;
|
||||
|
||||
private:
|
||||
char *data;
|
||||
size_t length;
|
||||
// size_t length;
|
||||
char *cursor;
|
||||
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