2012-05-14 12:00:00 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-14 15:40:31 +01:00
|
|
|
/*
|
2012-07-17 12:30:48 +01:00
|
|
|
* This file is part of the LibreOffice project.
|
2012-05-14 15:40:31 +01:00
|
|
|
*
|
|
|
|
* 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/.
|
|
|
|
*/
|
2012-07-17 12:30:48 +01:00
|
|
|
|
2012-07-05 13:54:17 +01:00
|
|
|
#include "basictest.hxx"
|
2013-11-11 21:25:36 -06:00
|
|
|
#include <osl/file.hxx>
|
|
|
|
#include <osl/process.h>
|
2012-05-14 12:00:00 +01:00
|
|
|
|
2013-11-11 21:25:36 -06:00
|
|
|
#include <basic/sbmod.hxx>
|
|
|
|
#include <basic/sbmeth.hxx>
|
2012-05-14 12:00:00 +01:00
|
|
|
namespace
|
|
|
|
{
|
2013-03-07 10:49:28 +00:00
|
|
|
class EnableTest : public test::BootstrapFixture
|
2012-05-14 12:00:00 +01:00
|
|
|
{
|
|
|
|
public:
|
2013-03-07 10:49:28 +00:00
|
|
|
EnableTest() : BootstrapFixture(true, false) {};
|
2012-05-14 12:00:00 +01:00
|
|
|
void testDimEnable();
|
2012-05-14 13:58:43 +01:00
|
|
|
void testEnableRuntime();
|
2012-05-14 12:00:00 +01:00
|
|
|
// Adds code needed to register the test suite
|
|
|
|
CPPUNIT_TEST_SUITE(EnableTest);
|
|
|
|
|
|
|
|
// Declares the method as a test to call
|
|
|
|
CPPUNIT_TEST(testDimEnable);
|
2012-05-14 13:58:43 +01:00
|
|
|
CPPUNIT_TEST(testEnableRuntime);
|
2012-05-14 12:00:00 +01:00
|
|
|
|
|
|
|
// End of test suite definition
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
};
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sTestEnableRuntime(
|
2013-03-07 10:49:28 +00:00
|
|
|
"Function doUnitTest as Integer\n"
|
2012-07-05 13:54:17 +01:00
|
|
|
"Dim Enable as Integer\n"
|
|
|
|
"Enable = 1\n"
|
|
|
|
"Enable = Enable + 2\n"
|
2013-03-07 10:49:28 +00:00
|
|
|
"doUnitTest = Enable\n"
|
2012-07-05 13:54:17 +01:00
|
|
|
"End Function\n"
|
|
|
|
);
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sTestDimEnable(
|
2013-03-07 10:49:28 +00:00
|
|
|
"Sub doUnitTest\n"
|
2012-07-05 13:54:17 +01:00
|
|
|
"Dim Enable as String\n"
|
|
|
|
"End Sub\n"
|
|
|
|
);
|
2012-05-14 12:00:00 +01:00
|
|
|
|
2012-05-14 13:58:43 +01:00
|
|
|
void EnableTest::testEnableRuntime()
|
2012-05-14 12:00:00 +01:00
|
|
|
{
|
2013-03-07 10:49:28 +00:00
|
|
|
MacroSnippet myMacro(sTestEnableRuntime);
|
|
|
|
myMacro.Compile();
|
|
|
|
CPPUNIT_ASSERT_MESSAGE("testEnableRuntime fails with compile error",!myMacro.HasError() );
|
|
|
|
SbxVariableRef pNew = myMacro.Run();
|
2016-07-22 09:14:24 +02:00
|
|
|
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(3), pNew->GetInteger());
|
2012-05-14 13:58:43 +01:00
|
|
|
}
|
2012-07-05 13:54:17 +01:00
|
|
|
|
2012-05-14 12:00:00 +01:00
|
|
|
void EnableTest::testDimEnable()
|
|
|
|
{
|
2013-03-07 10:49:28 +00:00
|
|
|
MacroSnippet myMacro(sTestDimEnable);
|
|
|
|
myMacro.Compile();
|
|
|
|
CPPUNIT_ASSERT_MESSAGE("Dim causes compile error", !myMacro.HasError() );
|
2012-05-14 12:00:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Put the test suite in the registry
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(EnableTest);
|
2016-01-30 22:12:35 +01:00
|
|
|
}
|
2012-05-14 12:00:00 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|