MCPcopy Create free account
hub / github.com/anjo76/angelscript / Test2

Function Test2

sdk/tests/test_feature/source/test_array.cpp:555–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555bool Test2()
556{
557 bool fail = false;
558
559 const char *script =
560 "class A \n"
561 "{ \n"
562 " int x; \n"
563 "} \n"
564 "int sum(const A[]& a) \n"
565 "{ \n"
566 " int s = 0; \n"
567 " for (uint i=0; i<a.length(); i++) \n"
568 " s+=a[i].x; \n"
569 " return s; \n"
570 "} \n";
571
572 const char *exec =
573 "A[] As; \n"
574 "As.resize(2); \n"
575 "As[0].x = 1; \n"
576 "As[1].x = 2; \n"
577 "sum(As); \n";
578
579 asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
580 RegisterScriptArray(engine, true);
581
582 asIScriptModule *module = engine->GetModule("module", asGM_ALWAYS_CREATE);
583
584 module->AddScriptSection("script", script);
585 int r = module->Build();
586 if( r < 0 )
587 {
588 TEST_FAILED;
589 }
590
591 r = ExecuteString(engine, exec, module);
592 if( r != asEXECUTION_FINISHED )
593 {
594 TEST_FAILED;
595 }
596
597 engine->Release();
598
599 return fail;
600}
601
602} // namespace
603

Callers 1

TestFunction · 0.70

Calls 6

RegisterScriptArrayFunction · 0.85
ExecuteStringFunction · 0.85
AddScriptSectionMethod · 0.80
GetModuleMethod · 0.45
BuildMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected