Skip to content

Commit 69171e4

Browse files
committed
Separate Test
1 parent 2294a7b commit 69171e4

31 files changed

+3163
-2629
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
using NUnit.Framework;
2+
using UnityEngine;
3+
4+
namespace UnitySensors.Tests.Editor
5+
{
6+
[TestFixture]
7+
public class BasicUnityTests
8+
{
9+
[Test]
10+
public void Vector3_Magnitude_ShouldCalculateCorrectly()
11+
{
12+
// Arrange
13+
var vector = new Vector3(3.0f, 4.0f, 0.0f);
14+
var expectedMagnitude = 5.0f;
15+
16+
// Act
17+
var magnitude = vector.magnitude;
18+
19+
// Assert
20+
Assert.AreEqual(expectedMagnitude, magnitude, 0.001f);
21+
}
22+
23+
[Test]
24+
public void Vector3_Normalize_ShouldReturnUnitVector()
25+
{
26+
// Arrange
27+
var vector = new Vector3(3.0f, 4.0f, 0.0f);
28+
29+
// Act
30+
var normalized = vector.normalized;
31+
32+
// Assert
33+
Assert.AreEqual(1.0f, normalized.magnitude, 0.001f);
34+
}
35+
36+
[Test]
37+
public void Quaternion_Identity_ShouldBeNoRotation()
38+
{
39+
// Arrange & Act
40+
var identity = Quaternion.identity;
41+
42+
// Assert
43+
Assert.AreEqual(0.0f, identity.x, 0.001f);
44+
Assert.AreEqual(0.0f, identity.y, 0.001f);
45+
Assert.AreEqual(0.0f, identity.z, 0.001f);
46+
Assert.AreEqual(1.0f, identity.w, 0.001f);
47+
}
48+
49+
[Test]
50+
public void Color_Components_ShouldBeAccessible()
51+
{
52+
// Arrange
53+
var color = new Color(0.8f, 0.6f, 0.4f, 1.0f);
54+
55+
// Act & Assert
56+
Assert.AreEqual(0.8f, color.r, 0.001f);
57+
Assert.AreEqual(0.6f, color.g, 0.001f);
58+
Assert.AreEqual(0.4f, color.b, 0.001f);
59+
Assert.AreEqual(1.0f, color.a, 0.001f);
60+
}
61+
62+
[Test]
63+
public void Vector2Int_Constructor_ShouldSetCorrectValues()
64+
{
65+
// Arrange
66+
var x = 640;
67+
var y = 480;
68+
69+
// Act
70+
var vector = new Vector2Int(x, y);
71+
72+
// Assert
73+
Assert.AreEqual(x, vector.x);
74+
Assert.AreEqual(y, vector.y);
75+
}
76+
77+
[Test]
78+
public void Transform_LocalPosition_ShouldDefaultToZero()
79+
{
80+
// Arrange
81+
var gameObject = new GameObject("TestObject");
82+
var transform = gameObject.transform;
83+
84+
// Act
85+
var position = transform.localPosition;
86+
87+
// Assert
88+
Assert.AreEqual(Vector3.zero, position);
89+
90+
// Cleanup
91+
Object.DestroyImmediate(gameObject);
92+
}
93+
94+
[Test]
95+
public void Transform_LocalRotation_ShouldDefaultToIdentity()
96+
{
97+
// Arrange
98+
var gameObject = new GameObject("TestObject");
99+
var transform = gameObject.transform;
100+
101+
// Act
102+
var rotation = transform.localRotation;
103+
104+
// Assert
105+
Assert.AreEqual(0.0f, rotation.x, 0.001f);
106+
Assert.AreEqual(0.0f, rotation.y, 0.001f);
107+
Assert.AreEqual(0.0f, rotation.z, 0.001f);
108+
Assert.AreEqual(1.0f, rotation.w, 0.001f);
109+
110+
// Cleanup
111+
Object.DestroyImmediate(gameObject);
112+
}
113+
114+
[Test]
115+
public void Mathf_Approximately_ShouldWorkCorrectly()
116+
{
117+
// Arrange
118+
var a = 1.0f;
119+
var b = 1.000001f;
120+
121+
// Act & Assert
122+
Assert.IsTrue(Mathf.Approximately(a, b));
123+
Assert.IsFalse(Mathf.Approximately(a, b + 0.1f));
124+
}
125+
126+
[Test]
127+
public void Time_DeltaTime_ShouldBePositive()
128+
{
129+
// Act
130+
var deltaTime = Time.deltaTime;
131+
132+
// Assert
133+
Assert.GreaterOrEqual(deltaTime, 0.0f);
134+
}
135+
}
136+
}

Assets/UnitySensors/Tests/Editor/BasicUnityTests.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using NUnit.Framework;
2+
3+
namespace UnitySensors.Tests.Editor
4+
{
5+
[TestFixture]
6+
public class GeoCoordinateBasicTests
7+
{
8+
[Test]
9+
public void GeoCoordinate_Reflection_ShouldBeAccessible()
10+
{
11+
// Test that GeoCoordinate can be accessed via reflection
12+
// Act & Assert
13+
Assert.DoesNotThrow(() => {
14+
var type = System.Type.GetType("UnitySensors.DataType.GeoCoordinate, UnitySensorsRuntime");
15+
if (type != null)
16+
{
17+
Assert.IsTrue(type.IsClass);
18+
Assert.IsTrue(type.IsPublic);
19+
20+
// Check for latitude and longitude fields
21+
var latField = type.GetField("latitude");
22+
var lonField = type.GetField("longitude");
23+
var altField = type.GetField("altitude");
24+
25+
if (latField != null) Assert.AreEqual(typeof(double), latField.FieldType);
26+
if (lonField != null) Assert.AreEqual(typeof(double), lonField.FieldType);
27+
if (altField != null) Assert.AreEqual(typeof(double), altField.FieldType);
28+
}
29+
});
30+
}
31+
32+
[Test]
33+
public void GeoCoordinate_ValidCoordinates_ShouldBeHandled()
34+
{
35+
// Test valid coordinate ranges
36+
// Act & Assert
37+
Assert.DoesNotThrow(() => {
38+
// Test latitude range (-90 to 90)
39+
var validLatitudes = new double[] { -90.0, -45.0, 0.0, 45.0, 90.0 };
40+
foreach (var lat in validLatitudes)
41+
{
42+
Assert.GreaterOrEqual(lat, -90.0);
43+
Assert.LessOrEqual(lat, 90.0);
44+
}
45+
46+
// Test longitude range (-180 to 180)
47+
var validLongitudes = new double[] { -180.0, -90.0, 0.0, 90.0, 180.0 };
48+
foreach (var lon in validLongitudes)
49+
{
50+
Assert.GreaterOrEqual(lon, -180.0);
51+
Assert.LessOrEqual(lon, 180.0);
52+
}
53+
54+
// Test altitude (typically above sea level, but can be negative)
55+
var validAltitudes = new double[] { -422.0, 0.0, 100.0, 8848.0 }; // Dead Sea to Everest
56+
foreach (var alt in validAltitudes)
57+
{
58+
Assert.GreaterOrEqual(alt, -500.0); // Reasonable lower bound
59+
Assert.LessOrEqual(alt, 10000.0); // Reasonable upper bound
60+
}
61+
});
62+
}
63+
64+
[Test]
65+
public void GeoCoordinate_Constructor_ShouldSetCorrectValues()
66+
{
67+
// Test coordinate construction concepts
68+
// Act & Assert
69+
Assert.DoesNotThrow(() => {
70+
// Test typical coordinate values
71+
var testCoordinates = new[] {
72+
new { lat = 35.6762, lon = 139.6503, alt = 0.0, name = "Tokyo" },
73+
new { lat = 40.7128, lon = -74.0060, alt = 10.0, name = "New York" },
74+
new { lat = 51.5074, lon = -0.1278, alt = 11.0, name = "London" }
75+
};
76+
77+
foreach (var coord in testCoordinates)
78+
{
79+
// Validate latitude
80+
Assert.GreaterOrEqual(coord.lat, -90.0);
81+
Assert.LessOrEqual(coord.lat, 90.0);
82+
83+
// Validate longitude
84+
Assert.GreaterOrEqual(coord.lon, -180.0);
85+
Assert.LessOrEqual(coord.lon, 180.0);
86+
87+
// Validate name
88+
Assert.IsNotNull(coord.name);
89+
Assert.IsTrue(coord.name.Length > 0);
90+
}
91+
});
92+
}
93+
}
94+
}

Assets/UnitySensors/Tests/Editor/GeoCoordinateBasicTests.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)