TestSqVM.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00027
00028 #include "../include/TestSqVM.h"
00029
00030 namespace ParCompMarkTest
00031 {
00032
00033 void TestSqVM::setUp()
00034 {
00035 std::string currentLogFile = "logs/TestSqVM.log";
00036
00037 if(Logger::getInstance() && Logger::getInstance()->getLogFileName() != currentLogFile)
00038 Logger::destroyInstance();
00039
00040 if(!FileSystemManager::getInstance())
00041 {
00042 FileSystemManager::createInstance();
00043 FileSystemManager::getInstance()->setAppDirectory("./");
00044 FileSystemManager::getInstance()->initialize();
00045 }
00046
00047 if(!Logger::getInstance())
00048 {
00049 Logger::createInstance();
00050 Logger::getInstance()->setLogFileName(currentLogFile);
00051 Logger::getInstance()->initialize();
00052 }
00053 }
00054
00055
00056
00057 void TestSqVM::tearDown()
00058 {
00059 }
00060
00061
00062
00063
00064
00065
00066
00067 void TestSqVM::test_constructor_cstd__string()
00068 {
00069
00070
00071
00072
00073
00074
00075
00076 SqVM::Pointer sqvm;
00077 CPPUNIT_ASSERT_NO_THROW(sqvm = new SqVM("TestVM"));
00078 }
00079
00080
00081
00082 void TestSqVM::test_destructor()
00083 {
00084
00085 }
00086
00087
00088
00089
00090
00091
00092
00093 void TestSqVM::test_printFunction___HSQUIRRELVM_cSQChar_p_()
00094 {
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 }
00106
00107
00108
00109
00110
00111
00112
00113 void TestSqVM::test_runScriptFromFile_cstd__string_cstd__string_cstd__list___std__string___cbool()
00114 {
00115
00116
00117
00118
00119
00120
00121
00122
00123 SqVM::Pointer sqvm(new SqVM("TestVM"));
00124 Logger::getInstance()->setConsoleLogLevel(Logger::DEBUG);
00125
00126 for(int i = 0; i < 10; i++)
00127 {
00128
00129
00130 CPPUNIT_ASSERT_NO_THROW(sqvm->runScriptFromFile("scripts/helloWorld.nut"));
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 }
00141 }
00142
00143
00144
00145 void TestSqVM::test_runScriptFromString_cstd__string_cstd__string_cstd__string_cstd__list___std__string___cbool()
00146 {
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 SqVM::Pointer sqvm(new SqVM("TestVM"));
00158 Logger::getInstance()->setConsoleLogLevel(Logger::DEBUG);
00159
00160
00161 CPPUNIT_ASSERT_NO_THROW(sqvm->runScriptFromString("print(\"Hello World!\\n\");", "", SqVM::NOMAINMETHOD));
00162
00163
00164 CPPUNIT_ASSERT_NO_THROW(sqvm->
00165 runScriptFromString("function main() { print(\"Hello World!\\n\"); }", "", "main"));
00166
00167
00168 CPPUNIT_ASSERT_NO_THROW(sqvm->
00169 runScriptFromString
00170 ("function main() { print(\"Hello World! This is my dynamic script. I will call it later, too.\\n\"); }",
00171 "myScript", "main"));
00172
00173
00174 CPPUNIT_ASSERT_THROW(sqvm->runScriptFromString("sdhfusid huisfh usifh suf", "", SqVM::NOMAINMETHOD),
00175 ParCompMark::Exception);
00176
00177
00178 CPPUNIT_ASSERT_NO_THROW(sqvm->runScriptFromString("", "myScript", "main"));
00179 }
00180
00181
00182
00183 void TestSqVM::test_runScriptByName_cstd__string_cstd__list___std__string__()
00184 {
00185
00186
00187
00188
00189
00190
00191
00192
00193 SqVM::Pointer sqvm(new SqVM("TestVM"));
00194 Logger::getInstance()->setConsoleLogLevel(Logger::DEBUG);
00195
00196
00197 Logger::getInstance()->log(Logger::DEBUG, "Calling `scripts/helloWorld.nut\' for 1st.");
00198 CPPUNIT_ASSERT_NO_THROW(sqvm->runScriptFromFile("scripts/helloWorld.nut"));
00199
00200
00201 Logger::getInstance()->log(Logger::DEBUG, "Calling `myScript\' for 1st.");
00202 CPPUNIT_ASSERT_NO_THROW(sqvm->
00203 runScriptFromString
00204 ("function dynamicMain() { print(\"Hello World! This is my dynamic script. I will call it later, too.\\n\"); }",
00205 "myScript", "dynamicMain"));
00206
00207 Logger::getInstance()->log(Logger::DEBUG, "Calling `scripts/helloWorld.nut\' again");
00208 CPPUNIT_ASSERT_NO_THROW(sqvm->runScriptByName("scripts/helloWorld.nut"));
00209 Logger::getInstance()->log(Logger::DEBUG, "Calling `myScript\' again");
00210 CPPUNIT_ASSERT_NO_THROW(sqvm->runScriptByName("myScript"));
00211 }
00212
00213
00214
00215 void TestSqVM::test_finalize()
00216 {
00217
00218
00219
00220
00221
00222
00223
00224 SqVM::Pointer sqvm1(new SqVM("TestVM1"));
00225 SqVM::Pointer sqvm2(new SqVM("TestVM2"));
00226
00227 CPPUNIT_ASSERT_NO_THROW(sqvm1->activate());
00228 CPPUNIT_ASSERT_NO_THROW(sqvm1->deactivate());
00229 CPPUNIT_ASSERT_NO_THROW(sqvm2->activate());
00230 CPPUNIT_ASSERT_NO_THROW(sqvm2->deactivate());
00231 CPPUNIT_ASSERT_NO_THROW(sqvm1->activate());
00232 CPPUNIT_ASSERT_NO_THROW(sqvm1->deactivate());
00233 }
00234
00235
00236
00237 void TestSqVM::test_activate()
00238 {
00239
00240
00241
00242
00243
00244
00245
00246
00247 }
00248
00249
00250
00251 void TestSqVM::test_deactivate()
00252 {
00253
00254
00255
00256
00257
00258
00259
00260
00261 }
00262
00263
00264
00265 void TestSqVM::test_initialize()
00266 {
00267
00268
00269
00270
00271
00272
00273
00274
00275 }
00276
00277
00278
00279 void TestSqVM::test_createScript_cstd__string_cbool_cstd__string_cbool()
00280 {
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290 CPPUNIT_FAIL("Implement this test!");
00291 }
00292
00293
00294
00295 void TestSqVM::test_findScript_cstd__string()
00296 {
00297
00298
00299
00300
00301
00302
00303
00304 CPPUNIT_FAIL("Implement this test!");
00305 }
00306
00307
00308
00309 void TestSqVM::test_findOrAddScript_cstd__string_cbool_cstd__string_cbool()
00310 {
00311
00312
00313
00314
00315
00316
00317
00318 SqVM::Pointer sqvm(new SqVM("TestVM"));
00319 SqVM::Script::Pointer script0, script1;
00320
00321
00322 CPPUNIT_ASSERT_NO_THROW(script0 = sqvm->findOrAddScript("test0.nut"));
00323 CPPUNIT_ASSERT(script0->compiled == false);
00324 CPPUNIT_ASSERT(script0->name == "test0.nut");
00325
00326
00327
00328
00329 CPPUNIT_ASSERT_NO_THROW(script1 = sqvm->findOrAddScript("test0.nut"));
00330 CPPUNIT_ASSERT(script0 == script1);
00331
00332
00333 CPPUNIT_ASSERT_NO_THROW(script1 = sqvm->findOrAddScript("test1.nut"));
00334 CPPUNIT_ASSERT(script0 != script1);
00335
00336
00337 CPPUNIT_ASSERT_NO_THROW(script0.unlock());
00338 CPPUNIT_ASSERT_NO_THROW(script1.unlock());
00339 }
00340
00341
00342
00343 void TestSqVM::test_compileAndExecuteScript_SqVM__Script__Pointer()
00344 {
00345
00346
00347
00348
00349
00350
00351
00352 CPPUNIT_FAIL("Implement this test!");
00353 }
00354
00355
00356
00357 void TestSqVM::test_setParameters_SqVM__Script__Pointer_cstd__list___std__string__()
00358 {
00359
00360
00361
00362
00363
00364
00365
00366 CPPUNIT_FAIL("Implement this test!");
00367 }
00368
00369
00370
00371
00373 CPPUNIT_TEST_SUITE_REGISTRATION(TestSqVM);
00374 }