Files
ResInsight/ApplicationLibCode/UnitTests/RimWorkflowVec3Binding-Test.cpp
T
Magne Sjaastad 9bfd91df90 Workflows: Add RimWorkflowVec3Binding for Vec3-typed config fields
Recognizes Vec3-shaped object schemas ({x, y, z} number properties)
structurally in RimWorkflowDescribeTools and dispatches them to a new
RimWorkflowVec3Binding in RimWorkflowTaskInput::createBinding(). Stores
the value as a cvf::Vec3d field, parses JSON object defaults, and emits
a YAML flow-mapping ({x: .., y: .., z: ..}) matching the taskmaestro
Vec3 pydantic model shape.
2026-10-05 19:56:36 +02:00

34 lines
1.3 KiB
C++

#include "gtest/gtest.h"
#include "RimWorkflowVec3Binding.h"
#include <QJsonObject>
//--------------------------------------------------------------------------------------------------
/// taskmaestro_resinsight.models.Vec3 is a plain pydantic model with x/y/z number fields, so both
/// the schema default and config_values represent it as a JSON object, not an array.
//--------------------------------------------------------------------------------------------------
TEST( RimWorkflowVec3Binding, AppliesObjectDefault )
{
RimWorkflowVec3Binding binding;
const QJsonObject schema{ { "name", "reference_point" },
{ "description", "Reference point" },
{ "required", true },
{ "default", QJsonObject{ { "x", 457196.0 }, { "y", 7322270.0 }, { "z", 2742.0 } } } };
binding.applySchema( schema );
EXPECT_EQ( "{x: 457196, y: 7322270, z: 2742}", binding.toYamlValue() );
}
//--------------------------------------------------------------------------------------------------
TEST( RimWorkflowVec3Binding, NoDefaultYieldsNullYaml )
{
RimWorkflowVec3Binding binding;
const QJsonObject schema{ { "name", "reference_point" }, { "required", true } };
binding.applySchema( schema );
EXPECT_EQ( "null", binding.toYamlValue() );
}