diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ConnectionHandlerTest/ConnectionHandlerTest.cbp | 69 | ||||
-rw-r--r-- | tests/ConnectionHandlerTest/ConnectionHandlerTest.cc | 135 | ||||
-rw-r--r-- | tests/ConnectionHandlerTest/ConnectionHandlerTest.depend | 1 | ||||
-rw-r--r-- | tests/ConnectionHandlerTest/ConnectionHandlerTest.layout | 9 | ||||
-rw-r--r-- | tests/ConnectionHandlerTest/ConnectionHandlerTest.layout.save | 9 | ||||
-rw-r--r-- | tests/CredentialPersistence/CredentialPersistence.cbp | 67 | ||||
-rw-r--r-- | tests/CredentialPersistence/CredentialPersistence.cbp.save | 67 | ||||
-rw-r--r-- | tests/CredentialPersistence/CredentialPersistence.cc | 85 | ||||
-rw-r--r-- | tests/CredentialPersistence/CredentialPersistence.depend | 1 | ||||
-rw-r--r-- | tests/CredentialPersistence/CredentialPersistence.layout | 9 | ||||
-rw-r--r-- | tests/CredentialPersistence/CredentialPersistence.layout.save | 9 | ||||
-rw-r--r-- | tests/JSonTest/JSonTest.cbp | 66 | ||||
-rw-r--r-- | tests/JSonTest/JSonTest.cbp.save | 66 | ||||
-rw-r--r-- | tests/JSonTest/JSonTest.cc | 68 | ||||
-rw-r--r-- | tests/JSonTest/JSonTest.depend | 18 | ||||
-rw-r--r-- | tests/JSonTest/JSonTest.layout | 9 |
16 files changed, 688 insertions, 0 deletions
diff --git a/tests/ConnectionHandlerTest/ConnectionHandlerTest.cbp b/tests/ConnectionHandlerTest/ConnectionHandlerTest.cbp new file mode 100644 index 0000000..b2d783b --- /dev/null +++ b/tests/ConnectionHandlerTest/ConnectionHandlerTest.cbp @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="Tests.ConnectionHandlerTest" /> + <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> + <Linker> + <Add library="../../libs/fsScan/libfsScan.a" /> + <Add library="../../libs/networking/libnetworking.a" /> + <Add library="../../libs/util/libutil.a" /> + <Add library="../../libs/vdr/libvdr.a" /> + <Add library="ssl" /> + <Add library="crypt" /> + </Linker> + </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="-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 -ansi" /> + <Add option="-D_REENTRANT" /> + <Add option="-D_GNU_SOURCE=1" /> + <Add directory="../../cmps/serverlib/include" /> + <Add directory="../../libs/fsScan/include" /> + <Add directory="../../libs/networking/include" /> + <Add directory="../../libs/util/include" /> + <Add directory="../../libs/vdr/include" /> + </Compiler> + <Linker> + <Add library="../../cmps/serverlib/libserverlib.a" /> + <Add library="../../libs/fsScan/libfsScan.a" /> + <Add library="../../libs/networking/libnetworking.a" /> + <Add library="../../libs/util/libutil.a" /> + <Add library="../../libs/vdr/libvdr.a" /> + <Add library="ssl" /> + <Add library="crypt" /> + <Add library="pthread" /> + <Add library="rt" /> + </Linker> + <Unit filename="ConnectionHandlerTest.cc" /> + <Extensions> + <code_completion /> + <envvars /> + <lib_finder disable_auto="1" /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/tests/ConnectionHandlerTest/ConnectionHandlerTest.cc b/tests/ConnectionHandlerTest/ConnectionHandlerTest.cc new file mode 100644 index 0000000..1dc3659 --- /dev/null +++ b/tests/ConnectionHandlerTest/ConnectionHandlerTest.cc @@ -0,0 +1,135 @@ +/* + * File: ConnectionHandlerTest.cc + * Author: django + * + * Created on 10.07.2012, 05:48:23 + */ +#include <ConnectionHandler.h> +#include <ServerConfig.h> +#include <FilesystemScanner.h> +#include <MediaFactory.h> +#include <MediaListHandler.h> +#include <MediaFileHandler.h> +#include <CommandHandler.h> +#include <JSonListAssembler.h> +#include <HTMLListAssembler.h> +#include <HTTPRequest.h> +#include <HTTPResponse.h> +#include <TimeMs.h> +#include <stdlib.h> +#include <iostream> +#include <stdio.h> +#include <sys/types.h> + +class cTestUnit { +public: + cTestUnit(const char *Name, cConnectionPoint &cp); + ~cTestUnit(); + + void test1(void); + void test2(void); + + const char *Name(void) const { return name; } + void SetUp(void); + +private: + cServerConfig config; + cConnectionHandler ch; + const char *name; + cFilesystemScanner *scanner; +}; + +cTestUnit::cTestUnit(const char* Name, cConnectionPoint &cp) + : config(12345) + , ch(cp, config) + , name(Name) + , scanner(NULL) +{ + config.SetAuthorizationRequired(false); + config.SetDocumentRoot("/media/video"); + config.SetAppIcon("/media/favicon.ico"); + + scanner = new cFilesystemScanner(); + if (!scanner) { + fprintf(stderr, "could not initialize application! (1)"); + exit(-1); + } + scanner->SetMediaFactory(new cMediaFactory(config.DocumentRoot())); + + cAbstractMediaRequestHandler::SetFilesystemScanner(scanner); + cConnectionHandler::RegisterRequestHandler("/cmd", new cCommandHandler()); + cMediaListHandler *listHandler = new cMediaListHandler(); + + listHandler->SetListAssembler("json", new cJSonListAssembler()); + listHandler->SetDefaultListAssembler(new cHTMLListAssembler()); + cConnectionHandler::RegisterRequestHandler("/", listHandler); + cConnectionHandler::RegisterDefaultHandler(new cMediaFileHandler()); +} + +cTestUnit::~cTestUnit() +{ + cCommandHandler::Cleanup(); + delete scanner; +} + +void cTestUnit::SetUp() +{ + if (scanner) scanner->Refresh(); +} + +void cTestUnit::test1() +{ + std::cout << "ConnectionHandlerTest test 1" << std::endl; + + cHTTPRequest rq(cHTTPRequest::GET, "/"); + + rq.SetHeader("Host", "localhost:43567"); + rq.SetHeader("User-Agent", "TestUnit"); + rq.SetHeader("Accept", "image/png,image/*;q=0.8,*/*;q=0.5"); + rq.SetHeader("Accept-Language", "de-de,de;q=0.8,en-us;q=0.5,en;q=0.3"); + rq.SetHeader("Accept-Encoding", "gzip,deflate"); + rq.SetHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); + rq.SetHeader("Keep-Alive", "300"); + rq.SetHeader("Connection", "keep-alive"); + + rq.Dump(); + cHTTPResponse *res = ch.ProcessRequest(rq); + + std::cout << "response looks like ..." << std::endl; + res->Dump(); + delete res; +} + +void cTestUnit::test2() +{ + std::cout << "ConnectionHandlerTest test 2" << std::endl; + std::cout << "%TEST_FAILED% time=0 testname=test2 (ConnectionHandlerTest) message=error message sample" << std::endl; +} + +int main(int argc, char** argv) +{ + uint64_t t0 = cTimeMs::Now(); + cConnectionPoint localHost("localhost", 40902); + cTestUnit unit("ConnectionHandlerTest", localHost); + + unit.SetUp(); + std::cout << "%SUITE_STARTING% " << unit.Name() << std::endl; + std::cout << "%SUITE_STARTED%" << std::endl; + + std::cout << "%TEST_STARTED% test1 (" << unit.Name() << ")" << std::endl; + uint64_t start = cTimeMs::Now(); + unit.test1(); + uint64_t end = cTimeMs::Now(); + std::cout << "%TEST_FINISHED% time=" << (double)(end - start) / 1000 << " test1 (" << unit.Name() << ")" << std::endl; + + std::cout << "%TEST_STARTED% test2 (" << unit.Name() << ")\n" << std::endl; + start = cTimeMs::Now(); + unit.test2(); + end = cTimeMs::Now(); + std::cout << "%TEST_FINISHED% time=" << (double)(end - start) / 1000 << " test2 (" << unit.Name() << ")" << std::endl; + + std::cout << "%SUITE_FINISHED% time=" << (double)(cTimeMs::Now() - t0) / 1000 << std::endl; + + return (EXIT_SUCCESS); +} + diff --git a/tests/ConnectionHandlerTest/ConnectionHandlerTest.depend b/tests/ConnectionHandlerTest/ConnectionHandlerTest.depend new file mode 100644 index 0000000..c4ac310 --- /dev/null +++ b/tests/ConnectionHandlerTest/ConnectionHandlerTest.depend @@ -0,0 +1 @@ +# depslib dependency file v1.0 diff --git a/tests/ConnectionHandlerTest/ConnectionHandlerTest.layout b/tests/ConnectionHandlerTest/ConnectionHandlerTest.layout new file mode 100644 index 0000000..84f2aab --- /dev/null +++ b/tests/ConnectionHandlerTest/ConnectionHandlerTest.layout @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_layout_file> + <ActiveTarget name="Debug" /> + <File name="ConnectionHandlerTest.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <Cursor> + <Cursor1 position="2048" topLine="0" /> + </Cursor> + </File> +</CodeBlocks_layout_file> diff --git a/tests/ConnectionHandlerTest/ConnectionHandlerTest.layout.save b/tests/ConnectionHandlerTest/ConnectionHandlerTest.layout.save new file mode 100644 index 0000000..84f2aab --- /dev/null +++ b/tests/ConnectionHandlerTest/ConnectionHandlerTest.layout.save @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_layout_file> + <ActiveTarget name="Debug" /> + <File name="ConnectionHandlerTest.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <Cursor> + <Cursor1 position="2048" topLine="0" /> + </Cursor> + </File> +</CodeBlocks_layout_file> diff --git a/tests/CredentialPersistence/CredentialPersistence.cbp b/tests/CredentialPersistence/CredentialPersistence.cbp new file mode 100644 index 0000000..0a5cfce --- /dev/null +++ b/tests/CredentialPersistence/CredentialPersistence.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.CredentialPersistence" /> + <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="-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 -ansi" /> + <Add option="-D_REENTRANT" /> + <Add option="-D_GNU_SOURCE=1" /> + <Add directory="../../cmps/serverlib/include" /> + <Add directory="../../libs/fsScan/include" /> + <Add directory="../../libs/networking/include" /> + <Add directory="../../libs/util/include" /> + <Add directory="../../libs/vdr/include" /> + </Compiler> + <Linker> + <Add library="../../cmps/serverlib/libserverlib.a" /> + <Add library="../../libs/fsScan/libfsScan.a" /> + <Add library="../../libs/networking/libnetworking.a" /> + <Add library="../../libs/util/libutil.a" /> + <Add library="../../libs/vdr/libvdr.a" /> + <Add library="jpeg" /> + <Add library="pthread" /> + <Add library="dl" /> + <Add library="cap" /> + <Add library="rt" /> + <Add library="fribidi" /> + <Add library="freetype" /> + <Add library="yajl" /> + <Add library="ssl" /> + <Add library="crypt" /> + </Linker> + <Unit filename="CredentialPersistence.cc" /> + <Extensions> + <code_completion /> + <envvars /> + <lib_finder disable_auto="1" /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/tests/CredentialPersistence/CredentialPersistence.cbp.save b/tests/CredentialPersistence/CredentialPersistence.cbp.save new file mode 100644 index 0000000..0a5cfce --- /dev/null +++ b/tests/CredentialPersistence/CredentialPersistence.cbp.save @@ -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.CredentialPersistence" /> + <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="-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 -ansi" /> + <Add option="-D_REENTRANT" /> + <Add option="-D_GNU_SOURCE=1" /> + <Add directory="../../cmps/serverlib/include" /> + <Add directory="../../libs/fsScan/include" /> + <Add directory="../../libs/networking/include" /> + <Add directory="../../libs/util/include" /> + <Add directory="../../libs/vdr/include" /> + </Compiler> + <Linker> + <Add library="../../cmps/serverlib/libserverlib.a" /> + <Add library="../../libs/fsScan/libfsScan.a" /> + <Add library="../../libs/networking/libnetworking.a" /> + <Add library="../../libs/util/libutil.a" /> + <Add library="../../libs/vdr/libvdr.a" /> + <Add library="jpeg" /> + <Add library="pthread" /> + <Add library="dl" /> + <Add library="cap" /> + <Add library="rt" /> + <Add library="fribidi" /> + <Add library="freetype" /> + <Add library="yajl" /> + <Add library="ssl" /> + <Add library="crypt" /> + </Linker> + <Unit filename="CredentialPersistence.cc" /> + <Extensions> + <code_completion /> + <envvars /> + <lib_finder disable_auto="1" /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/tests/CredentialPersistence/CredentialPersistence.cc b/tests/CredentialPersistence/CredentialPersistence.cc new file mode 100644 index 0000000..8dc2347 --- /dev/null +++ b/tests/CredentialPersistence/CredentialPersistence.cc @@ -0,0 +1,85 @@ +/* + * File: CredentialPersistence.cc + * Author: django + * + * Created on 03.07.2012, 14:16:35 + */ +#include <Principal.h> +#include <Credentials.h> +#include <stdlib.h> +#include <iostream> + +/* + * Simple C++ Test Suite + */ +static void setupTestCredentials() { + Credentials.SetApplicationRealm("supportedUsers@myTestApp"); + cPrincipal *p = new cPrincipal("Nasenbär", Credentials.ApplicationRealm()); + + p->CreateHash("Nasenwasser"); + Credentials.Put(p->Name(), p); + + p = new cPrincipal("Admin", Credentials.ApplicationRealm()); + p->CreateHash("very secret"); + Credentials.Put(p->Name(), p); + + p = new cPrincipal("Sepp", Credentials.ApplicationRealm()); + p->CreateHash("keine Ahnung"); + Credentials.Put(p->Name(), p); +} + +static void dumpCredentials() { + cCredentials::const_iterator principals = Credentials.begin(); + + while (principals != Credentials.end()) { + principals->second->Dump(); + ++principals; + } + +} + +void test1() +{ + setupTestCredentials(); + std::cout << "CredentialPersistence test 1" << std::endl; + + int rv = Credentials.Store("/tmp/testCredentials.x9"); + + if (!rv) std::cout << "%TEST_FAILED% time=0 testname=test1 (CredentialPersistence) message=failed to write credentials" << std::endl; + else std::cout << "saved " << rv << " principals." << std::endl; + + dumpCredentials(); +} + +void test2() +{ + std::cout << "CredentialPersistence test 2" << std::endl; + + Credentials.Clear(); + + int rv = Credentials.Load("/tmp/testCredentials.x9"); + + if (!rv) std::cout << "%TEST_FAILED% time=0 testname=test2 (CredentialPersistence) message=failed to load credentials" << std::endl; + else std::cout << "loaded " << rv << " principals." << std::endl; + + dumpCredentials(); +} + +int main(int argc, char** argv) +{ + std::cout << "%SUITE_STARTING% CredentialPersistence" << std::endl; + std::cout << "%SUITE_STARTED%" << std::endl; + + std::cout << "%TEST_STARTED% test1 (CredentialPersistence)" << std::endl; + test1(); + std::cout << "%TEST_FINISHED% time=0 test1 (CredentialPersistence)" << std::endl; + + std::cout << "%TEST_STARTED% test2 (CredentialPersistence)\n" << std::endl; + test2(); + std::cout << "%TEST_FINISHED% time=0 test2 (CredentialPersistence)" << std::endl; + + std::cout << "%SUITE_FINISHED% time=0" << std::endl; + + return (EXIT_SUCCESS); +} + diff --git a/tests/CredentialPersistence/CredentialPersistence.depend b/tests/CredentialPersistence/CredentialPersistence.depend new file mode 100644 index 0000000..c4ac310 --- /dev/null +++ b/tests/CredentialPersistence/CredentialPersistence.depend @@ -0,0 +1 @@ +# depslib dependency file v1.0 diff --git a/tests/CredentialPersistence/CredentialPersistence.layout b/tests/CredentialPersistence/CredentialPersistence.layout new file mode 100644 index 0000000..abb8444 --- /dev/null +++ b/tests/CredentialPersistence/CredentialPersistence.layout @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_layout_file> + <ActiveTarget name="Debug" /> + <File name="CredentialPersistence.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <Cursor> + <Cursor1 position="99" topLine="0" /> + </Cursor> + </File> +</CodeBlocks_layout_file> diff --git a/tests/CredentialPersistence/CredentialPersistence.layout.save b/tests/CredentialPersistence/CredentialPersistence.layout.save new file mode 100644 index 0000000..abb8444 --- /dev/null +++ b/tests/CredentialPersistence/CredentialPersistence.layout.save @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_layout_file> + <ActiveTarget name="Debug" /> + <File name="CredentialPersistence.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <Cursor> + <Cursor1 position="99" topLine="0" /> + </Cursor> + </File> +</CodeBlocks_layout_file> diff --git a/tests/JSonTest/JSonTest.cbp b/tests/JSonTest/JSonTest.cbp new file mode 100644 index 0000000..9328615 --- /dev/null +++ b/tests/JSonTest/JSonTest.cbp @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="Tests.JSonTest" /> + <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="-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 -ansi" /> + <Add option="-D_REENTRANT" /> + <Add option="-D_GNU_SOURCE=1" /> + <Add directory="../../libs/fsScan/include" /> + <Add directory="../../libs/networking/include" /> + <Add directory="../../libs/util/include" /> + <Add directory="../../libs/vdr/include" /> + </Compiler> + <Linker> + <Add library="../../libs/fsScan/libfsScan.a" /> + <Add library="../../libs/networking/libnetworking.a" /> + <Add library="../../libs/util/libutil.a" /> + <Add library="../../libs/vdr/libvdr.a" /> + <Add library="jpeg" /> + <Add library="pthread" /> + <Add library="dl" /> + <Add library="cap" /> + <Add library="rt" /> + <Add library="fribidi" /> + <Add library="freetype" /> + <Add library="fontconfig" /> + <Add library="yajl" /> + <Add library="ssl" /> + <Add library="crypt" /> + </Linker> + <Unit filename="JSonTest.cc" /> + <Extensions> + <code_completion /> + <envvars /> + <lib_finder disable_auto="1" /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/tests/JSonTest/JSonTest.cbp.save b/tests/JSonTest/JSonTest.cbp.save new file mode 100644 index 0000000..9328615 --- /dev/null +++ b/tests/JSonTest/JSonTest.cbp.save @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="Tests.JSonTest" /> + <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="-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 -ansi" /> + <Add option="-D_REENTRANT" /> + <Add option="-D_GNU_SOURCE=1" /> + <Add directory="../../libs/fsScan/include" /> + <Add directory="../../libs/networking/include" /> + <Add directory="../../libs/util/include" /> + <Add directory="../../libs/vdr/include" /> + </Compiler> + <Linker> + <Add library="../../libs/fsScan/libfsScan.a" /> + <Add library="../../libs/networking/libnetworking.a" /> + <Add library="../../libs/util/libutil.a" /> + <Add library="../../libs/vdr/libvdr.a" /> + <Add library="jpeg" /> + <Add library="pthread" /> + <Add library="dl" /> + <Add library="cap" /> + <Add library="rt" /> + <Add library="fribidi" /> + <Add library="freetype" /> + <Add library="fontconfig" /> + <Add library="yajl" /> + <Add library="ssl" /> + <Add library="crypt" /> + </Linker> + <Unit filename="JSonTest.cc" /> + <Extensions> + <code_completion /> + <envvars /> + <lib_finder disable_auto="1" /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/tests/JSonTest/JSonTest.cc b/tests/JSonTest/JSonTest.cc new file mode 100644 index 0000000..c4500c1 --- /dev/null +++ b/tests/JSonTest/JSonTest.cc @@ -0,0 +1,68 @@ +/* + * File: JSonTest.cc + * Author: django + * + * Created on 12.07.2012, 07:31:46 + */ + +#include <StringBuilder.h> +#include <JSonWriter.h> +#include <stdlib.h> +#include <iostream> + +/* + * Simple C++ Test Suite + */ + +void test1() +{ + char buf[512] = {0}; + cStringBuilder sb; + cJSonWriter jw(sb); + + std::cout << "JSonTest test 1" << std::endl; + + jw.Object().Key("total").Value(123); + jw.Key("errorCode").Value(-1); + jw.Key("testmode").Value(true); + jw.Key("results").Array(); + + for (int i=0; i < 3; ++i) { + jw.Object().Key("counter").Value(i); + jw.Key("nase").Value("bär"); + jw.EndObject(); + } + jw.EndArray(); + jw.Key("fasel").Value("blub"); + jw.EndObject(); + + std::cout << "size of json-Object: " << sb.Size() << std::endl; + sb.Copy(buf, sizeof(buf)); + + std::cout << "json object looks like" << std::endl << buf << std::endl; +} + +void test2() +{ + std::cout << "JSonTest test 2" << std::endl; + std::cout << "%TEST_FAILED% time=0 testname=test2 (JSonTest) message=error message sample" << std::endl; +} + +int main(int argc, char** argv) +{ + std::cout << "%SUITE_STARTING% JSonTest" << std::endl; + std::cout << "%SUITE_STARTED%" << std::endl; + + std::cout << "%TEST_STARTED% test1 (JSonTest)" << std::endl; + test1(); + std::cout << "%TEST_FINISHED% time=0 test1 (JSonTest)" << std::endl; + +// std::cout << "%TEST_STARTED% test2 (JSonTest)\n" << std::endl; +// test2(); +// std::cout << "%TEST_FINISHED% time=0 test2 (JSonTest)" << std::endl; + + std::cout << "%SUITE_FINISHED% time=0" << std::endl; + + return (EXIT_SUCCESS); +} + diff --git a/tests/JSonTest/JSonTest.depend b/tests/JSonTest/JSonTest.depend new file mode 100644 index 0000000..deeec5d --- /dev/null +++ b/tests/JSonTest/JSonTest.depend @@ -0,0 +1,18 @@ +# depslib dependency file v1.0 +1342071807 source:/d/linux/CMP/tests/JSonTest/JSonTest.cc + <StringBuilder.h> + <JSonWriter.h> + <stdlib.h> + <iostream> + +1342076412 /d/linux/CMP/libs/util/include/StringBuilder.h + <ManagedVector.h> + <time.h> + +1341942404 /d/linux/CMP/libs/util/include/ManagedVector.h + <vector> + <stdlib.h> + +1342076888 /d/linux/CMP/libs/util/include/JSonWriter.h + <stack> + diff --git a/tests/JSonTest/JSonTest.layout b/tests/JSonTest/JSonTest.layout new file mode 100644 index 0000000..a4583b3 --- /dev/null +++ b/tests/JSonTest/JSonTest.layout @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_layout_file> + <ActiveTarget name="Debug" /> + <File name="JSonTest.cc" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <Cursor> + <Cursor1 position="340" topLine="0" /> + </Cursor> + </File> +</CodeBlocks_layout_file> |