I'm sure these things are easier to troubleshoot when I remember to
include the patch :)


August Sodora
aug...@gmail.com
(201) 280-8138



On Mon, Oct 17, 2011 at 10:01 AM, August Sodora <aug...@gmail.com> wrote:
>> I am terribly sorry, but got distracted by the LibreOffice conference,
>> and was not able to have a look at your updated patch :-(
>
> No worries :) It gave me a lot of good time to read the code and try
> to understand the problem better.
>
>> If you have any tests now, would be great to send them too, I believe it
>> will help me evaluate your patch too.
>
> I started writing a test fixture to try and pull apart exactly what is
> going on in the basic scanner but I ran into a build issue. I followed
> the instructions on
> http://wiki.documentfoundation.org/Development/Unit_Tests but get some
> errors:
>
> /home/aasodora/Sources/libo/basic/qa/cppunit/test_scanner.cxx:78:
> undefined reference to `SbiScanner::SbiScanner(rtl::OUString const&,
> StarBASIC*)'
>
> Sorry for being such a noob, thank you all for your patience!
>
> August Sodora
> aug...@gmail.com
> (201) 280-8138
>
>
>
> On Mon, Oct 17, 2011 at 8:58 AM, Jan Holesovsky <ke...@suse.cz> wrote:
>> Hi August,
>>
>> On 2011-10-07 at 16:01 -0400, August Sodora wrote:
>>
>>> Has anybody had a chance to review this patch? I'm really interested
>>> in writing some tests for basic and I'd like to make sure that these
>>> types of changes are on the right track.
>>
>> I am terribly sorry, but got distracted by the LibreOffice conference,
>> and was not able to have a look at your updated patch :-(
>>
>> If you have any tests now, would be great to send them too, I believe it
>> will help me evaluate your patch too.
>>
>> Thank you a lot,
>> Kendy
>>
>>
>
From c38f7a997f31df05d288825c494ef9656c5e569a 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 |   18 +++++++
 basic/Module_basic.mk              |    4 ++
 basic/qa/cppunit/test_scanner.cxx  |   92 ++++++++++++++++++++++++++++++++++++
 3 files changed, 114 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..091792b
--- /dev/null
+++ b/basic/CppunitTest_basic_scanner.mk
@@ -0,0 +1,18 @@
+$(eval $(call gb_CppunitTest_CppunitTest,basic_scanner))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,basic_scanner, \
+basic/qa/cppunit/test_scanner \
+))
+
+# add a list of all needed libraries here
+$(eval $(call gb_CppunitTest_add_linked_libs,basic_scanner, \
+sal \
+$(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.4.4

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to