Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
cac7e7cd
Kaydet (Commit)
cac7e7cd
authored
Tem 05, 2012
tarafından
Noel Power
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
split out some common basic test stuff, add intial nested struct test
Change-Id: I8da6b3166e40e92c31ee001ce19938f286e057b9
üst
2fab1a73
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
46 deletions
+139
-46
Module_basic.mk
basic/Module_basic.mk
+1
-0
basictest.hxx
basic/qa/cppunit/basictest.hxx
+51
-0
test_append.cxx
basic/qa/cppunit/test_append.cxx
+24
-46
test_nested_struct.cxx
basic/qa/cppunit/test_nested_struct.cxx
+63
-0
No files found.
basic/Module_basic.mk
Dosyayı görüntüle @
cac7e7cd
...
...
@@ -37,6 +37,7 @@ $(eval $(call gb_Module_add_targets,basic,\
$(eval $(call gb_Module_add_check_targets,basic,\
CppunitTest_basic_scanner \
CppunitTest_basic_enable \
CppunitTest_basic_nested_struct \
))
endif
...
...
basic/qa/cppunit/basictest.hxx
0 → 100644
Dosyayı görüntüle @
cac7e7cd
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2012 LibreOffice contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _BASICTEST_HXX
#define _BASICTEST_HXX
#include <sal/types.h>
#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
#include <test/bootstrapfixture.hxx>
#include "basic/sbstar.hxx"
#include "basic/basrdll.hxx"
class
BasicTestBase
:
public
test
::
BootstrapFixture
{
private
:
bool
mbError
;
public
:
BasicTestBase
()
:
mbError
(
false
)
{};
DECL_LINK
(
BasicErrorHdl
,
StarBASIC
*
);
bool
HasError
()
{
return
mbError
;
}
void
ResetError
()
{
StarBASIC
::
SetGlobalErrorHdl
(
Link
()
);
mbError
=
false
;
}
BasicDLL
&
basicDLL
()
{
static
BasicDLL
maDll
;
// we need a dll instance for resouce manager etc.
return
maDll
;
}
};
IMPL_LINK
(
BasicTestBase
,
BasicErrorHdl
,
StarBASIC
*
,
/*pBasic*/
)
{
fprintf
(
stderr
,
"Got error:
\n\t
%s!!!
\n
"
,
rtl
::
OUStringToOString
(
StarBASIC
::
GetErrorText
(),
RTL_TEXTENCODING_UTF8
).
getStr
()
);
mbError
=
true
;
return
0
;
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basic/qa/cppunit/test_append.cxx
Dosyayı görüntüle @
cac7e7cd
...
...
@@ -6,30 +6,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sal/types.h>
#include "cppunit/TestAssert.h"
#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
#include <test/bootstrapfixture.hxx>
#include "basictest.hxx"
#include "osl/file.hxx"
#include "osl/process.h"
#include "basic/sbstar.hxx"
#include "basic/sbmod.hxx"
#include "basic/sbmeth.hxx"
#include "basic/basrdll.hxx"
namespace
{
class
EnableTest
:
public
test
::
BootstrapFixtur
e
class
EnableTest
:
public
BasicTestBas
e
{
private
:
bool
mbError
;
public
:
EnableTest
()
:
mbError
(
false
)
{};
EnableTest
()
{};
void
testDimEnable
();
void
testEnableRuntime
();
// Adds code needed to register the test suite
...
...
@@ -41,63 +29,53 @@ namespace
// End of test suite definition
CPPUNIT_TEST_SUITE_END
();
DECL_LINK
(
BasicErrorHdl
,
StarBASIC
*
);
bool
HasError
()
{
return
mbError
;
}
BasicDLL
&
basicDLL
()
{
static
BasicDLL
maDll
;
// we need a dll instance for resouce manager etc.
return
maDll
;
}
};
IMPL_LINK
(
EnableTest
,
BasicErrorHdl
,
StarBASIC
*
,
/*pBasic*/
)
{
fprintf
(
stderr
,
"Got error:
\n\t
%s!!!
\n
"
,
rtl
::
OUStringToOString
(
StarBASIC
::
GetErrorText
(),
RTL_TEXTENCODING_UTF8
).
getStr
()
);
mbError
=
true
;
return
0
;
}
rtl
::
OUString
sTestEnableRuntime
(
"Function Test as Integer
\n
"
"Dim Enable as Integer
\n
"
"Enable = 1
\n
"
"Enable = Enable + 2
\n
"
"Test = Enable
\n
"
"End Function
\n
"
);
rtl
::
OUString
sTestDimEnable
(
"Sub Test
\n
"
"Dim Enable as String
\n
"
"End Sub
\n
"
);
void
EnableTest
::
testEnableRuntime
()
{
CPPUNIT_ASSERT_MESSAGE
(
"No resource manager"
,
basicDLL
().
GetBasResMgr
()
!=
NULL
);
StarBASICRef
pBasic
=
new
StarBASIC
();
ResetError
();
StarBASIC
::
SetGlobalErrorHdl
(
LINK
(
this
,
EnableTest
,
BasicErrorHdl
)
);
rtl
::
OUString
sSource
(
"Function Test as Integer
\n
"
);
sSource
+=
rtl
::
OUString
(
"Dim Enable as Integer
\n
"
);
sSource
+=
rtl
::
OUString
(
"Enable = 1
\n
"
);
sSource
+=
rtl
::
OUString
(
"Enable = Enable + 2
\n
"
);
sSource
+=
rtl
::
OUString
(
"Test = Enable
\n
"
);
sSource
+=
rtl
::
OUString
(
"End Function
\n
"
);
SbModule
*
pMod
=
pBasic
->
MakeModule
(
rtl
::
OUString
(
"TestModule"
),
sSource
);
SbModule
*
pMod
=
pBasic
->
MakeModule
(
rtl
::
OUString
(
"TestModule"
),
sTestEnableRuntime
);
pMod
->
Compile
();
CPPUNIT_ASSERT_MESSAGE
(
"testEnableRuntime fails with compile error"
,
!
mbError
);
CPPUNIT_ASSERT_MESSAGE
(
"testEnableRuntime fails with compile error"
,
!
HasError
()
);
SbMethod
*
pMeth
=
static_cast
<
SbMethod
*>
(
pMod
->
Find
(
rtl
::
OUString
(
"Test"
),
SbxCLASS_METHOD
));
CPPUNIT_ASSERT_MESSAGE
(
"testEnableRuntime no method found"
,
pMeth
);
SbxVariableRef
refTemp
=
pMeth
;
// forces a broadcast
SbxVariableRef
pNew
=
new
SbxMethod
(
*
((
SbxMethod
*
)
pMeth
));
CPPUNIT_ASSERT
(
pNew
->
GetInteger
()
==
3
);
StarBASIC
::
SetGlobalErrorHdl
(
Link
()
);
}
void
EnableTest
::
testDimEnable
()
{
CPPUNIT_ASSERT_MESSAGE
(
"No resource manager"
,
basicDLL
().
GetBasResMgr
()
!=
NULL
);
StarBASICRef
pBasic
=
new
StarBASIC
();
StarBASIC
::
SetGlobalErrorHdl
(
LINK
(
this
,
EnableTest
,
BasicErrorHdl
)
);
rtl
::
OUString
sSource
(
"Sub Test
\n
"
);
sSource
+=
rtl
::
OUString
(
"Dim Enable as String
\n
"
);
sSource
+=
rtl
::
OUString
(
"End Sub
\n
"
);
ResetError
();
SbModule
*
pMod
=
pBasic
->
MakeModule
(
rtl
::
OUString
(
"TestModule"
),
s
Sourc
e
);
SbModule
*
pMod
=
pBasic
->
MakeModule
(
rtl
::
OUString
(
"TestModule"
),
s
TestDimEnabl
e
);
pMod
->
Compile
();
CPPUNIT_ASSERT_MESSAGE
(
"Dim causes compile error"
,
!
mbError
);
StarBASIC
::
SetGlobalErrorHdl
(
Link
()
);
CPPUNIT_ASSERT_MESSAGE
(
"Dim causes compile error"
,
!
HasError
()
);
}
// Put the test suite in the registry
...
...
basic/qa/cppunit/test_nested_struct.cxx
0 → 100644
Dosyayı görüntüle @
cac7e7cd
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2012 LibreOffice contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "basictest.hxx"
#include "osl/file.hxx"
#include "osl/process.h"
#include "basic/sbmod.hxx"
#include "basic/sbmeth.hxx"
namespace
{
class
Nested_Struct
:
public
BasicTestBase
{
public
:
Nested_Struct
()
{};
void
testAssign1
();
// Adds code needed to register the test suite
CPPUNIT_TEST_SUITE
(
Nested_Struct
);
// Declares the method as a test to call
CPPUNIT_TEST
(
testAssign1
);
// End of test suite definition
CPPUNIT_TEST_SUITE_END
();
};
rtl
::
OUString
sTestSource1
(
"Function simpleNestStructAccess() as Integer
\n
"
"Dim b0 as new
\"
com.sun.star.table.TableBorder
\"\n
"
"b0.HorizontalLine.OuterLineWidth = 9
\n
"
"simpleNestStructAccess = b0.HorizontalLine.OuterLineWidth
\n
"
"End Function
\n
"
);
void
Nested_Struct
::
testAssign1
()
{
CPPUNIT_ASSERT_MESSAGE
(
"No resource manager"
,
basicDLL
().
GetBasResMgr
()
!=
NULL
);
StarBASICRef
pBasic
=
new
StarBASIC
();
ResetError
();
StarBASIC
::
SetGlobalErrorHdl
(
LINK
(
this
,
Nested_Struct
,
BasicErrorHdl
)
);
SbModule
*
pMod
=
pBasic
->
MakeModule
(
rtl
::
OUString
(
"TestModule"
),
sTestSource1
);
pMod
->
Compile
();
CPPUNIT_ASSERT_MESSAGE
(
"testAssign1 fails with compile error"
,
!
HasError
()
);
SbMethod
*
pMeth
=
static_cast
<
SbMethod
*>
(
pMod
->
Find
(
rtl
::
OUString
(
"simpleNestStructAccess"
),
SbxCLASS_METHOD
));
CPPUNIT_ASSERT_MESSAGE
(
"testAssign1 no method found"
,
pMeth
);
SbxVariableRef
refTemp
=
pMeth
;
// forces a broadcast
SbxVariableRef
pNew
=
new
SbxMethod
(
*
((
SbxMethod
*
)
pMeth
));
CPPUNIT_ASSERT
(
pNew
->
GetInteger
()
==
9
);
}
// Put the test suite in the registry
CPPUNIT_TEST_SUITE_REGISTRATION
(
Nested_Struct
);
}
// namespace
CPPUNIT_PLUGIN_IMPLEMENT
();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment