1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "basictest.hxx"
12 #include <cppunit/TestAssert.h>
13 #include <cppunit/TestFixture.h>
14 #include <cppunit/extensions/HelperMacros.h>
18 class Language_Conditionals
: public CppUnit::TestFixture
25 CPPUNIT_TEST_SUITE(Language_Conditionals
);
27 CPPUNIT_TEST(testIfNot
);
28 CPPUNIT_TEST(testIfAndNot
);
29 CPPUNIT_TEST(testNENot
);
31 CPPUNIT_TEST_SUITE_END();
34 void Language_Conditionals::testIfNot()
36 { // need a block to ensure MacroSnippet is cleaned properly
37 MacroSnippet
myMacro("Option VBASupport 1\n"
40 "Function doUnitTest() As Integer\n"
41 "Dim op1 As Boolean\n"
50 CPPUNIT_ASSERT(!myMacro
.HasError());
51 SbxVariableRef pNew
= myMacro
.Run();
52 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), pNew
->GetInteger());
54 { // need a block to ensure MacroSnippet is cleaned properly
55 MacroSnippet
myMacro("Option VBASupport 0\n"
58 "Function doUnitTest() As Integer\n"
59 "Dim op1 As Boolean\n"
68 CPPUNIT_ASSERT(!myMacro
.HasError());
69 SbxVariableRef pNew
= myMacro
.Run();
70 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), pNew
->GetInteger());
74 void Language_Conditionals::testIfAndNot()
76 { // need a block to ensure MacroSnippet is cleaned properly
77 MacroSnippet
myMacro("Option VBASupport 1\n"
80 "Function doUnitTest() As Integer\n"
81 "Dim op1 As Boolean\n"
82 "Dim op2 As Boolean\n"
85 "If op1 And Not op2 Then\n"
92 CPPUNIT_ASSERT(!myMacro
.HasError());
93 SbxVariableRef pNew
= myMacro
.Run();
94 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), pNew
->GetInteger());
96 { // need a block to ensure MacroSnippet is cleaned properly
97 MacroSnippet
myMacro("Option VBASupport 0\n"
100 "Function doUnitTest() As Integer\n"
101 "Dim op1 As Boolean\n"
102 "Dim op2 As Boolean\n"
105 "If op1 And Not op2 Then\n"
112 CPPUNIT_ASSERT(!myMacro
.HasError());
113 SbxVariableRef pNew
= myMacro
.Run();
114 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), pNew
->GetInteger());
118 void Language_Conditionals::testNENot()
120 { // need a block to ensure MacroSnippet is cleaned properly
121 MacroSnippet
myMacro("Option VBASupport 1\n"
124 "Function doUnitTest() As Integer\n"
125 "Dim op1 As Boolean\n"
126 "Dim op2 As Boolean\n"
129 "If op1 <> Not op2 Then\n"
136 CPPUNIT_ASSERT(!myMacro
.HasError());
137 SbxVariableRef pNew
= myMacro
.Run();
138 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), pNew
->GetInteger());
140 { // need a block to ensure MacroSnippet is cleaned properly
141 MacroSnippet
myMacro("Option VBASupport 0\n"
144 "Function doUnitTest() As Integer\n"
145 "Dim op1 As Boolean\n"
146 "Dim op2 As Boolean\n"
149 "If op1 <> Not op2 Then\n"
156 CPPUNIT_ASSERT(!myMacro
.HasError());
157 SbxVariableRef pNew
= myMacro
.Run();
158 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(1), pNew
->GetInteger());
162 CPPUNIT_TEST_SUITE_REGISTRATION(Language_Conditionals
);
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */