| 7 | #include "utils.h" |
| 8 | |
| 9 | bool TestCreateEngine() |
| 10 | { |
| 11 | bool fail = false; |
| 12 | asIScriptEngine *engine = asCreateScriptEngine(); |
| 13 | if( engine == 0 ) |
| 14 | { |
| 15 | // Failure |
| 16 | PRINTF("TestCreateEngine: asCreateScriptEngine() failed\n"); |
| 17 | TEST_FAILED; |
| 18 | } |
| 19 | else |
| 20 | { |
| 21 | // Set a message callback |
| 22 | CBufferedOutStream bout; |
| 23 | engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL); |
| 24 | |
| 25 | // Although it's not recommended that two engines are created, it shouldn't be a problem |
| 26 | asIScriptEngine *engine2 = asCreateScriptEngine(); |
| 27 | if( engine2 == 0 ) |
| 28 | { |
| 29 | // Failure |
| 30 | PRINTF("TestCreateEngine: asCreateScriptEngine() failed for 2nd engine\n"); |
| 31 | TEST_FAILED; |
| 32 | } |
| 33 | else |
| 34 | { |
| 35 | // Attempt to reuse the message callback from the first engine |
| 36 | asSFuncPtr msgCallback; |
| 37 | void* obj; |
| 38 | asDWORD callConv; |
| 39 | engine->GetMessageCallback(&msgCallback, &obj, &callConv); |
| 40 | engine2->SetMessageCallback(msgCallback, obj, callConv); |
| 41 | |
| 42 | engine2->WriteMessage("test", 0, 0, asMSGTYPE_INFORMATION, "Hello from engine2"); |
| 43 | |
| 44 | engine2->ShutDownAndRelease(); |
| 45 | } |
| 46 | |
| 47 | engine->ShutDownAndRelease(); |
| 48 | |
| 49 | if (bout.buffer != "test (0, 0) : Info : Hello from engine2\n") |
| 50 | { |
| 51 | PRINTF("%s", bout.buffer.c_str()); |
| 52 | TEST_FAILED; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return fail; |
| 57 | } |
no test coverage detected