浏览代码

more coverage (and update coverage settings)

/v2-staging-rebase
Chris Elion 4 年前
当前提交
02df360d
共有 7 个文件被更改,包括 80 次插入39 次删除
  1. 2
      DevProject/Packages/manifest.json
  2. 8
      DevProject/Packages/packages-lock.json
  3. 18
      DevProject/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json
  4. 4
      DevProject/ProjectSettings/ProjectVersion.txt
  5. 24
      com.unity.ml-agents/Runtime/InplaceArray.cs
  6. 52
      com.unity.ml-agents/Tests/Editor/InplaceArrayTests.cs
  7. 11
      com.unity.ml-agents/Tests/Editor/ObservationSpecTests.cs

2
DevProject/Packages/manifest.json


"com.unity.package-manager-doctools": "1.7.0-preview",
"com.unity.package-validation-suite": "0.19.0-preview",
"com.unity.purchasing": "2.2.1",
"com.unity.test-framework": "1.1.20",
"com.unity.test-framework": "1.1.22",
"com.unity.test-framework.performance": "2.2.0-preview",
"com.unity.testtools.codecoverage": "1.0.0-pre.3",
"com.unity.textmeshpro": "2.0.1",

8
DevProject/Packages/packages-lock.json


"url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"
},
"com.unity.barracuda": {
"version": "1.3.0-preview",
"version": "1.3.1-preview",
"depth": 1,
"source": "registry",
"dependencies": {

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.barracuda": "1.3.0-preview",
"com.unity.barracuda": "1.3.1-preview",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.physics": "1.0.0",

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.ml-agents": "1.7.2-preview"
"com.unity.ml-agents": "1.8.0-preview"
}
},
"com.unity.multiplayer-hlapi": {

"url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"
},
"com.unity.test-framework": {
"version": "1.1.20",
"version": "1.1.22",
"depth": 0,
"source": "registry",
"dependencies": {

18
DevProject/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json


"m_Name": "Settings",
"m_Path": "ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json",
"m_Dictionary": {
"m_DictionaryValues": []
"m_DictionaryValues": [
{
"type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "Path",
"value": "{\"m_Value\":\"{ProjectPath}\"}"
},
{
"type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "HistoryPath",
"value": "{\"m_Value\":\"{ProjectPath}\"}"
},
{
"type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "IncludeAssemblies",
"value": "{\"m_Value\":\"Assembly-CSharp,Runtime,Unity.ML-Agents,Unity.ML-Agents.Extensions\"}"
}
]
}
}

4
DevProject/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2019.4.19f1
m_EditorVersionWithRevision: 2019.4.19f1 (ca5b14067cec)
m_EditorVersion: 2019.4.20f1
m_EditorVersionWithRevision: 2019.4.20f1 (6dd1c08eedfa)

24
com.unity.ml-agents/Runtime/InplaceArray.cs


{
m_Length = 1;
m_elem0 = elem0;
m_elem1 = new T { };
m_elem2 = new T { };
m_elem3 = new T { };
m_elem1 = new T {};
m_elem2 = new T {};
m_elem3 = new T {};
}
public InplaceArray(T elem0, T elem1)

m_elem1 = elem1;
m_elem2 = new T { };
m_elem3 = new T { };
m_elem2 = new T {};
m_elem3 = new T {};
}
public InplaceArray(T elem0, T elem1, T elem2)

m_elem1 = elem1;
m_elem2 = elem2;
m_elem3 = new T { };
m_elem3 = new T {};
}
public InplaceArray(T elem0, T elem1, T elem2, T elem3)

{
get
{
if (index < 0 || index >= Length)
if (index >= Length)
{
throw new IndexOutOfRangeException();
}

set
{
if (index < 0 || index >= Length)
if (index >= Length)
{
throw new IndexOutOfRangeException();
}

{
switch (m_Length)
{
case 0:
return "[]";
case 1:
return $"[{m_elem0}]";
case 2:

}
}
public static bool operator ==(InplaceArray<T> lhs, InplaceArray<T> rhs)
public static bool operator==(InplaceArray<T> lhs, InplaceArray<T> rhs)
{
if (lhs.Length != rhs.Length)
{

return true;
}
public static bool operator !=(InplaceArray<T> lhs, InplaceArray<T> rhs) => !(lhs == rhs);
public static bool operator!=(InplaceArray<T> lhs, InplaceArray<T> rhs) => !(lhs == rhs);
public override bool Equals(object other) => other is InplaceArray<T> other1 && this.Equals(other1);

public override int GetHashCode()
{
// TODO need to switch on length?
}
}

52
com.unity.ml-agents/Tests/Editor/InplaceArrayTests.cs


namespace Unity.MLAgents.Tests
{
[TestFixture]
public class InplaceArrayTests
{

[TestCaseSource(typeof(LengthCases))]
public void TestInplaceGetSet(int length)
{
var original = GetTestArray(length);
var original = GetTestArray(length);
for (var i = 0; i < original.Length; i++)
for (var i = 0; i < original.Length; i++)
{
var modified = original;
modified[i] = 0;
for (var j = 0; j < original.Length; j++)
var modified = original;
modified[i] = 0;
for (var j = 0; j < original.Length; j++)
if (i == j)
if (i == j)
{
// This is the one we overwrote
Assert.AreEqual(0, modified[j]);
}
else
{
// Other elements should be unchanged
Assert.AreEqual(original[j], modified[j]);
}
// This is the one we overwrote
Assert.AreEqual(0, modified[j]);
}
else
{
// Other elements should be unchanged
Assert.AreEqual(original[j], modified[j]);
}
}
[TestCaseSource(typeof(LengthCases))]

}
}
[Test]
public void TestToString()
{
Assert.AreEqual("[1]", new InplaceArray<int>(1).ToString());
Assert.AreEqual("[1, 2]", new InplaceArray<int>(1, 2).ToString());
Assert.AreEqual("[1, 2, 3]", new InplaceArray<int>(1, 2, 3).ToString());
Assert.AreEqual("[1, 2, 3, 4]", new InplaceArray<int>(1, 2, 3, 4).ToString());
}
[TestCaseSource(typeof(LengthCases))]
public void TestFromList(int length)
{
var intArray = new int[length];
for (var i = 0; i < length; i++)
{
intArray[i] = (i + 1) * 11; // 11, 22, etc.
}
var converted = InplaceArray<int>.FromList(intArray);
Assert.AreEqual(GetTestArray(length), converted);
}
}
}

11
com.unity.ml-agents/Tests/Editor/ObservationSpecTests.cs


Assert.AreEqual(ObservationType.Default, obsSpec.ObservationType);
}
[Test]
public void TestMismatchShapeDimensionPropThrows()
{
var shape = new InplaceArray<int>(1, 2);
var dimProps = new InplaceArray<DimensionProperty>(DimensionProperty.TranslationalEquivariance);
Assert.Throws<UnityAgentsException>(() =>
{
new ObservationSpec(shape, dimProps);
});
}
}
}
正在加载...
取消
保存