浏览代码

fixed float range tests

/usim-randomization
Steven Leal 4 年前
当前提交
52558327
共有 3 个文件被更改,包括 4 次插入4 次删除
  1. 4
      com.unity.perception/Runtime/Randomization/Configuration/ParameterConfiguration.cs
  2. 2
      com.unity.perception/Runtime/Randomization/Samplers/FloatRange.cs
  3. 2
      com.unity.perception/Tests/Runtime/Randomization/SamplerTests/FloatRangeTests.cs

4
com.unity.perception/Runtime/Randomization/Configuration/ParameterConfiguration.cs


foreach (var parameter in parameters)
{
if (parameterNames.Contains(parameter.name))
throw new ParameterConfigurationException($"Two or more parameters cannot share the same name " +
$"(\"{parameter.name}\")");
throw new ParameterConfigurationException(
$"Two or more parameters cannot share the same name (\"{parameter.name}\")");
parameterNames.Add(parameter.name);
parameter.Validate();
}

2
com.unity.perception/Runtime/Randomization/Samplers/FloatRange.cs


/// <exception cref="ArgumentException"></exception>
public void Validate()
{
Assert.IsTrue(minimum > maximum);
Assert.IsTrue(minimum <= maximum);
}
}
}

2
com.unity.perception/Tests/Runtime/Randomization/SamplerTests/FloatRangeTests.cs


[Test]
public void InvalidRange()
{
Assert.Throws<ArgumentException>(() => new FloatRange(1, -1).Validate());
Assert.Throws<UnityEngine.Assertions.AssertionException>(() => new FloatRange(1, -1).Validate());
}
}
}
正在加载...
取消
保存