fix: close STEP-073 QBIN2 V4 validator audit
This commit is contained in:
@@ -90,34 +90,36 @@ TEST(ParticleFieldProfileValidator, EnforcesVelocityDirectionAndValidityCoreRule
|
||||
EXPECT_EQ(particle::FieldUnitMetersPerSecond, 1);
|
||||
EXPECT_EQ(particle::FieldUnitDegrees, 4);
|
||||
auto c = contract(); auto f = frame(); const auto bytes = f.planes.front().storage;
|
||||
f.planes.push_back(plane(10, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
f.planes.push_back(plane(100, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
particle::FieldComponent::UEast, particle::FieldDType::Int16, false, bytes));
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidVelocityGroup);
|
||||
f.planes.push_back(plane(11, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
f.planes.push_back(plane(101, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
particle::FieldComponent::VNorth, particle::FieldDType::Int16, false, bytes));
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::Accepted);
|
||||
f.planes.back().unitID = 99;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidCoreUnit);
|
||||
f = frame();
|
||||
f.planes.push_back(plane(10, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 0,
|
||||
f.planes.push_back(plane(100, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 0,
|
||||
particle::FieldComponent::UEast, particle::FieldDType::Int16, false, bytes));
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidVelocityGroup);
|
||||
f = frame();
|
||||
f.planes.push_back(plane(10, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
f.planes.push_back(plane(100, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
particle::FieldComponent::UEast, particle::FieldDType::Int16, false, bytes));
|
||||
f.planes.push_back(plane(11, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
f.planes.push_back(plane(101, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
particle::FieldComponent::UEast, particle::FieldDType::Int16, false, bytes));
|
||||
f.planes.push_back(plane(12, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
f.planes.push_back(plane(102, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 3,
|
||||
particle::FieldComponent::VNorth, particle::FieldDType::Int16, false, bytes));
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidVelocityGroup);
|
||||
f = frame(); f.planes.front().valueClass = particle::FieldValueClass::DirectionAngle;
|
||||
f = frame(); f.planes.front().key.semanticID = 10; f.planes.front().valueClass = particle::FieldValueClass::DirectionAngle;
|
||||
f.planes.front().unitID = particle::FieldUnitDegrees;
|
||||
c.requiredPlanes.front().valueClass = particle::FieldValueClass::DirectionAngle;
|
||||
f.planes.front().dtype = particle::FieldDType::UInt16;
|
||||
f.planes.front().scale = 360.0f / 65536.0f;
|
||||
c.requiredPlanes.front().semanticID = 10; c.requiredPlanes.front().valueClass = particle::FieldValueClass::DirectionAngle;
|
||||
c.requiredPlanes.front().unitID = particle::FieldUnitDegrees;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::Accepted);
|
||||
f.planes.front().unitID = 2;
|
||||
c.requiredPlanes.front().unitID = 2;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidCoreUnit);
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::SemanticContractMismatch);
|
||||
c = contract(); f = frame(); f.validityPlane.dtype = particle::FieldDType::UInt8;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidCoreUnit);
|
||||
f = frame(); f.validityPlane.unitID = 1;
|
||||
@@ -126,6 +128,61 @@ TEST(ParticleFieldProfileValidator, EnforcesVelocityDirectionAndValidityCoreRule
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidCoreUnit);
|
||||
}
|
||||
|
||||
TEST(ParticleFieldProfileValidator, EnforcesReservedCoreSemanticContractsFromProtocolTable) {
|
||||
auto c = contract(); auto f = frame();
|
||||
// Contract and frame agree on the spoof, but reserved semantic 1 remains
|
||||
// VELOCITY_COMPONENT/MPS/U_EAST and cannot become an opaque scalar.
|
||||
c.requiredPlanes.front().semanticID = 1;
|
||||
f.planes.front().key.semanticID = 1;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::SemanticContractMismatch);
|
||||
|
||||
c = contract(); f = frame();
|
||||
c.requiredPlanes.front() = {2, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 4,
|
||||
particle::FieldComponent::UEast, true};
|
||||
f.planes.front() = plane(2, particle::FieldValueClass::VelocityComponent, particle::FieldUnitMetersPerSecond, 4,
|
||||
particle::FieldComponent::UEast, particle::FieldDType::Int16, true,
|
||||
f.planes.front().storage, "u-spoof");
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::SemanticContractMismatch);
|
||||
|
||||
c = contract(); f = frame();
|
||||
c.requiredPlanes.back().semanticID = 3;
|
||||
c.requiredPlanes.back().valueClass = particle::FieldValueClass::Scalar;
|
||||
f.validityPlane.key.semanticID = 3;
|
||||
f.validityPlane.valueClass = particle::FieldValueClass::Scalar;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::SemanticContractMismatch);
|
||||
}
|
||||
|
||||
TEST(ParticleFieldProfileValidator, EnforcesDirectionCircularQuantizationContract) {
|
||||
auto c = contract(); auto f = frame();
|
||||
c.requiredPlanes.front() = {10, particle::FieldValueClass::DirectionAngle, particle::FieldUnitDegrees, 0,
|
||||
particle::FieldComponent::None, true};
|
||||
f.planes.front() = plane(10, particle::FieldValueClass::DirectionAngle, particle::FieldUnitDegrees, 0,
|
||||
particle::FieldComponent::None, particle::FieldDType::UInt16, true,
|
||||
f.planes.front().storage, "direction");
|
||||
f.planes.front().scale = 360.0f / 65536.0f;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::Accepted);
|
||||
|
||||
f.planes.front().unitID = particle::FieldUnitMetersPerSecond;
|
||||
c.requiredPlanes.front().unitID = particle::FieldUnitMetersPerSecond;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::SemanticContractMismatch);
|
||||
f.planes.front().unitID = particle::FieldUnitDegrees;
|
||||
c.requiredPlanes.front().unitID = particle::FieldUnitDegrees;
|
||||
f.planes.front().key.component = particle::FieldComponent::UEast;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::SemanticContractMismatch);
|
||||
f.planes.front().key.component = particle::FieldComponent::None;
|
||||
f.planes.front().key.groupID = 1;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::SemanticContractMismatch);
|
||||
f.planes.front().key.groupID = 0;
|
||||
f.planes.front().dtype = particle::FieldDType::UInt8;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidCoreUnit);
|
||||
f.planes.front().dtype = particle::FieldDType::UInt16;
|
||||
f.planes.front().scale = 0.1f;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidCoreUnit);
|
||||
f.planes.front().scale = 360.0f / 65536.0f;
|
||||
f.planes.front().offset = 1.0f;
|
||||
EXPECT_EQ(validate(c, f), particle::FieldProfileValidationCode::InvalidCoreUnit);
|
||||
}
|
||||
|
||||
TEST(ParticleFieldProfileValidator, UsesSemanticAndGroupAsTheOnlyPlaneIdentity) {
|
||||
auto f = frame();
|
||||
auto duplicate = f.planes.front();
|
||||
|
||||
Reference in New Issue
Block a user