Added testing function for ZString.

This commit is contained in:
Brad Arant 2021-09-22 18:01:54 -07:00
parent 191899fbb7
commit a0129273b3
8 changed files with 99 additions and 70 deletions

View File

@ -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));

View File

@ -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();

View File

@ -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()));
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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

Binary file not shown.

17
testing/zstring_test.cpp Normal file
View 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;
}