Hello August, as promised on IRC this patch resolves all linking problems.
If you have any more problems feel free to ask here or on IRC. Thanks a lot for your work. Markus
From 4dff8234882606797b41b99fbc9d419b72c1f8ef Mon Sep 17 00:00:00 2001 From: August Sodora <aug...@gmail.com> Date: Mon, 17 Oct 2011 09:54:24 -0400 Subject: [PATCH] Added test skeleton to basic --- basic/CppunitTest_basic_scanner.mk | 33 +++++++++++++ basic/Module_basic.mk | 4 ++ basic/qa/cppunit/test_scanner.cxx | 92 ++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 0 deletions(-) create mode 100644 basic/CppunitTest_basic_scanner.mk create mode 100644 basic/qa/cppunit/test_scanner.cxx diff --git a/basic/CppunitTest_basic_scanner.mk b/basic/CppunitTest_basic_scanner.mk new file mode 100644 index 0000000..bf8237c --- /dev/null +++ b/basic/CppunitTest_basic_scanner.mk @@ -0,0 +1,33 @@ +$(eval $(call gb_CppunitTest_CppunitTest,basic_scanner)) + +$(eval $(call gb_CppunitTest_add_exception_objects,basic_scanner, \ + basic/qa/cppunit/test_scanner \ +)) + +$(eval $(call gb_CppunitTest_add_library_objects,basic_scanner,sb)) + +# add a list of all needed libraries here +$(eval $(call gb_CppunitTest_add_linked_libs,basic_scanner, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + salhelper \ + sb \ + sfx \ + sot \ + svl \ + svt \ + tl \ + utl \ + vcl \ + xcr \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_CppunitTest_set_include,basic_scanner,\ +-I$(realpath $(SRCDIR)/basic/source/inc) \ +-I$(realpath $(SRCDIR)/basic/inc) \ +$$(INCLUDE) \ +-I$(OUTDIR)/inc \ +)) diff --git a/basic/Module_basic.mk b/basic/Module_basic.mk index e7f9393..d1b5dee 100644 --- a/basic/Module_basic.mk +++ b/basic/Module_basic.mk @@ -37,4 +37,8 @@ $(eval $(call gb_Module_add_targets,basic,\ StaticLibrary_sample \ )) +$(eval $(call gb_Module_add_check_targets,basic,\ + CppunitTest_basic_scanner \ +)) + # vim: set noet sw=4 ts=4: diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx new file mode 100644 index 0000000..28d5bc7 --- /dev/null +++ b/basic/qa/cppunit/test_scanner.cxx @@ -0,0 +1,92 @@ +#include "sal/config.h" +#include "sal/precppunit.hxx" + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" + +#include "osl/file.hxx" +#include "osl/process.h" + +#include "scanner.hxx" + +namespace +{ +/** + * Perform tests on Scanner. + */ +class ScannerTest : public CppUnit::TestFixture +{ +private: + rtl::OUString cwd; + + /** + * Tests capability Foo of the class. + */ + void testFoo(); + + // Adds code needed to register the test suite + CPPUNIT_TEST_SUITE(ScannerTest); + // Declares the method as a test to call + CPPUNIT_TEST(testFoo); + // End of test suite definition + CPPUNIT_TEST_SUITE_END(); +public: + void setUp() + { + CPPUNIT_ASSERT(osl_getProcessWorkingDir(&cwd.pData) == osl_Process_E_None); + } + + void tearDown() + { + } +}; + +void ScannerTest::testFoo() +{ + const static rtl::OUString relPath(RTL_CONSTASCII_USTRINGPARAM("source/sample/sample.bas")); + + rtl::OUString fileUrl; + CPPUNIT_ASSERT(osl::FileBase::getAbsoluteFileURL(cwd, relPath, fileUrl) == osl::FileBase::E_None); + + printf(rtl::OUStringToOString(fileUrl, RTL_TEXTENCODING_UTF8).getStr()); + printf("\n"); + + osl::File file(fileUrl); + CPPUNIT_ASSERT(file.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None); + + sal_uInt64 size; + CPPUNIT_ASSERT(file.getSize(size) == osl::FileBase::E_None); + CPPUNIT_ASSERT(size > 0); + + sal_Char* buf = new sal_Char[size]; + sal_uInt64 bytesRead; + CPPUNIT_ASSERT(file.read(buf, size, bytesRead) == osl::FileBase::E_None); + + CPPUNIT_ASSERT(bytesRead == size); + + rtl::OString byteStr(buf, size - 1); + rtl::OUString source = rtl::OStringToOUString(rtl::OString(buf, size - 1), + RTL_TEXTENCODING_UTF8); + + printf(rtl::OUStringToOString(source, RTL_TEXTENCODING_UTF8).getStr()); + printf("\n"); + + CPPUNIT_ASSERT(file.close() == osl::FileBase::E_None); + + SbiScanner scanner(source); + + while(scanner.NextSym()) + { + ::rtl::OUString sym = scanner.GetSym(); + printf(rtl::OUStringToOString(sym, RTL_TEXTENCODING_UTF8).getStr()); + printf("\n"); + } +} + +// Put the test suite in the registry +CPPUNIT_TEST_SUITE_REGISTRATION(ScannerTest); + +} // namespace +CPPUNIT_PLUGIN_IMPLEMENT(); -- 1.7.3.4
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice