diff options
Diffstat (limited to 'tests/StringBuilderTest')
-rw-r--r-- | tests/StringBuilderTest/StringBuilderTest.cbp | 67 | ||||
-rw-r--r-- | tests/StringBuilderTest/StringBuilderTest.depend | 1 | ||||
-rw-r--r-- | tests/StringBuilderTest/StringBuilderTest.layout | 9 | ||||
-rw-r--r-- | tests/StringBuilderTest/main.cpp | 76 | ||||
l--------- | tests/StringBuilderTest/srclient.conf | 1 |
5 files changed, 154 insertions, 0 deletions
diff --git a/tests/StringBuilderTest/StringBuilderTest.cbp b/tests/StringBuilderTest/StringBuilderTest.cbp new file mode 100644 index 0000000..bc86f1b --- /dev/null +++ b/tests/StringBuilderTest/StringBuilderTest.cbp @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="Tests.StringBuilderTest" /> + <Option pch_mode="2" /> + <Option compiler="gcc" /> + <Build> + <Target title="Debug"> + <Option output="bin/Debug/Tests" prefix_auto="1" extension_auto="1" /> + <Option object_output="obj/Debug/" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-g" /> + </Compiler> + </Target> + <Target title="Release"> + <Option output="bin/Release/Tests" prefix_auto="1" extension_auto="1" /> + <Option object_output="obj/Release/" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-O2" /> + </Compiler> + <Linker> + <Add option="-s" /> + </Linker> + </Target> + </Build> + <Compiler> + <Add option="-Wall" /> + <Add option="-fexceptions -std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration" /> + <Add option="-D_REENTRANT" /> + <Add option="-D_GNU_SOURCE=1" /> + <Add option="-D_FILE_OFFSET_BITS=64" /> + <Add option="-D_LARGEFILE_SOURCE" /> + <Add option="-D_LARGEFILE64_SOURCE" /> + <Add option="-D__STDC_CONSTANT_MACROS" /> + <Add option="-D__STDC_FORMAT_MACROS" /> + <Add option="-D__STDC_LIMIT_MACROS" /> + <Add directory="../../libs/vdr/include" /> + <Add directory="../../libs/util/include" /> + <Add directory="../../libs/IO/include" /> + <Add directory="../../libs/networking/include" /> + <Add directory="../../libs/fsScan/include" /> + </Compiler> + <Linker> + <Add library="pthread" /> + <Add library="rt" /> + <Add library="ssl" /> + <Add library="crypt" /> + <Add library="../../libs/fsScan/libfsScan.a" /> + <Add library="../../libs/networking/libnetworking.a" /> + <Add library="../../libs/IO/libIO.a" /> + <Add library="../../libs/util/libutil.a" /> + <Add library="../../libs/vdr/libvdr.a" /> + </Linker> + <Unit filename="main.cpp" /> + <Extensions> + <code_completion /> + <envvars /> + <lib_finder disable_auto="1" /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/tests/StringBuilderTest/StringBuilderTest.depend b/tests/StringBuilderTest/StringBuilderTest.depend new file mode 100644 index 0000000..c4ac310 --- /dev/null +++ b/tests/StringBuilderTest/StringBuilderTest.depend @@ -0,0 +1 @@ +# depslib dependency file v1.0 diff --git a/tests/StringBuilderTest/StringBuilderTest.layout b/tests/StringBuilderTest/StringBuilderTest.layout new file mode 100644 index 0000000..a2754af --- /dev/null +++ b/tests/StringBuilderTest/StringBuilderTest.layout @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_layout_file> + <ActiveTarget name="Debug" /> + <File name="main.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <Cursor> + <Cursor1 position="1759" topLine="0" /> + </Cursor> + </File> +</CodeBlocks_layout_file> diff --git a/tests/StringBuilderTest/main.cpp b/tests/StringBuilderTest/main.cpp new file mode 100644 index 0000000..c06034a --- /dev/null +++ b/tests/StringBuilderTest/main.cpp @@ -0,0 +1,76 @@ +/* + * small tests for class StringBuilder + */ +#include <StringBuilder.h> +#include <FileReader.h> +#include <LineReader.h> +#include <File.h> +#include <string.h> +#include <iostream> + +#define NEW_LINE '\n' + +void rangeTests() +{ // 12345678901 + static const char *sample = "Hello World"; + cStringBuilder *sb; + int chunkSize = strlen(sample) - 4; + char *result; + + std::cout << sample << " has length: " << strlen(sample) << std::endl; + + for (int i=0; i < 6; ++i) { + std::cout << "check chunkSize of " << chunkSize + i << std::endl; + sb = new cStringBuilder(chunkSize + i); + + sb->Append(sample).Append(NEW_LINE); + result = sb->toString(); + + std::cout << "assembled text looks like: " << std::endl << result; + free(result); + delete sb; + } +} + +void basicTests() +{ + cStringBuilder sb(179); + + sb.Append("hello World").Append(NEW_LINE); + sb.Append("logical default true: ").Append(true).Append(NEW_LINE); + sb.Append("logical default false: ").Append(false).Append(NEW_LINE); + sb.Append("logical true value: ").Append(true, "true", "false").Append(NEW_LINE); + sb.Append("logical false value: ").Append(false, "true", "false").Append(NEW_LINE); + sb.Append("double: ").Append(3.1456789).Append(NEW_LINE); + sb.Append("unsigned long: ").Append((size_t) 91237485l).Append(NEW_LINE); + sb.Append("long: ").Append(1234567890l).Append(NEW_LINE); + sb.Append("int: ").Append(512).Append(NEW_LINE); + + char *result = sb.toString(); + + std::cout << "sizeof assembled text: " << sb.Size() << std::endl; + std::cout << "assembled text looks like:" << std::endl << result; + + free(result); +} + +void lineReaderTest() +{ + cLineReader lr(new cFileReader(new cFile("srclient.conf"))); + const char *line = NULL; + + while ((line = lr.ReadLine())) { + std::cout << "line: " << line << std::endl; + } + lr.Close(); + cFile::Cleanup(); +} + +int main() +{ + lineReaderTest(); + basicTests(); + rangeTests(); + + return 0; +} diff --git a/tests/StringBuilderTest/srclient.conf b/tests/StringBuilderTest/srclient.conf new file mode 120000 index 0000000..a159926 --- /dev/null +++ b/tests/StringBuilderTest/srclient.conf @@ -0,0 +1 @@ +/home/django/.cmp/srclient.conf
\ No newline at end of file |