mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Fix evaluatef argument handling and add regression test
This commit is contained in:
parent
1278a97edc
commit
6de2b455c4
3 changed files with 40 additions and 3 deletions
|
|
@ -50,10 +50,13 @@ namespace Con
|
||||||
/// NOTE: This function restores the console stack on return.
|
/// NOTE: This function restores the console stack on return.
|
||||||
inline EvalResult evaluatef(const char* string, ...)
|
inline EvalResult evaluatef(const char* string, ...)
|
||||||
{
|
{
|
||||||
|
char buffer[4096];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, string);
|
va_start(args, &string);
|
||||||
EvalResult result = setLastEvalResult(getRuntime()->evaluatef(string, args));
|
dVsprintf(buffer, sizeof(buffer), string, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
EvalResult result = setLastEvalResult(getRuntime()->evaluate(buffer));
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ namespace TorqueScript
|
||||||
{
|
{
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, string);
|
va_start(args, &string);
|
||||||
dVsprintf(buffer, sizeof(buffer), string, args);
|
dVsprintf(buffer, sizeof(buffer), string, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return evaluate(buffer);
|
return evaluate(buffer);
|
||||||
|
|
|
||||||
34
Engine/source/testing/inspectorFieldTest.cpp
Normal file
34
Engine/source/testing/inspectorFieldTest.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <gui/editor/inspector/group.h>
|
||||||
|
|
||||||
|
#include "console/script.h"
|
||||||
|
#include "T3D/fx/particle.h"
|
||||||
|
#include "T3D/gameBase/gameBase.h"
|
||||||
|
|
||||||
|
TEST(InspectoreFieldTest, Datablocks_Can_Be_Overridden)
|
||||||
|
{
|
||||||
|
GuiInspector* inspector = new GuiInspector();
|
||||||
|
inspector->registerObject();
|
||||||
|
|
||||||
|
ParticleData* exampleObj = new ParticleData();
|
||||||
|
exampleObj->registerObject();
|
||||||
|
// Add it to inspector so inspector field can find it
|
||||||
|
inspector->addInspectObject(exampleObj);
|
||||||
|
|
||||||
|
AbstractClassRep::Field* field = const_cast<AbstractClassRep::Field*>(exampleObj->findField(StringTable->insert("lifetimeMS")));
|
||||||
|
|
||||||
|
GuiInspectorGroup* group = new GuiInspectorGroup("testing", NULL);
|
||||||
|
ASSERT_TRUE(group->registerObject());
|
||||||
|
|
||||||
|
GuiInspectorField* inspectorField = new GuiInspectorField(inspector, group, field);
|
||||||
|
ASSERT_TRUE(inspectorField->registerObject());
|
||||||
|
|
||||||
|
inspectorField->setData("12345");
|
||||||
|
EXPECT_EQ(exampleObj->lifetimeMS, 12345);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
inspectorField->deleteObject();
|
||||||
|
group->deleteObject();
|
||||||
|
inspector->deleteObject();
|
||||||
|
exampleObj->deleteObject();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue