• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MeltyPlayer / MeltyTool / 26548448806

28 May 2026 01:11AM UTC coverage: 41.227% (-0.2%) from 41.395%
26548448806

push

github

web-flow
Specified the version for lcov merger since the newer one doesn't work for whatever reason.

7037 of 19097 branches covered (36.85%)

Branch coverage included in aggregate %.

30027 of 70806 relevant lines covered (42.41%)

61608.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/FinModelUtility/Fin/Fin.Testing/src/GoldenAssert_Model.cs
1
using fin.io;
2
using fin.util.asserts;
3
using fin.util.exceptions;
4

5
using Microsoft.VisualStudio.TestTools.UnitTesting;
6

7
using SharpGLTF.Schema2;
8

9

10
namespace fin.testing;
11

12
public static partial class GoldenAssert {
13
  private static void AssertModelFilesAreIdentical_(
14
      IReadOnlyTreeFile lhs,
15
      IReadOnlyTreeFile rhs) {
×
16
    var lhsModel = ParseModelFromBytes_(lhs);
×
17
    var rhsModel = ParseModelFromBytes_(rhs);
×
18

19
    AssertAnimationsIdentical_(
×
20
        lhsModel.LogicalAnimations,
×
21
        rhsModel.LogicalAnimations);
×
22

23
    AssertMaterialsIdentical_(
×
24
        lhsModel.LogicalMaterials,
×
25
        rhsModel.LogicalMaterials);
×
26

27
    AssertSkinsIdentical_(
×
28
        lhsModel.LogicalSkins,
×
29
        rhsModel.LogicalSkins);
×
30

31
    AssertMeshesIdentical_(
×
32
        lhsModel.LogicalMeshes,
×
33
        rhsModel.LogicalMeshes);
×
34

35
    AssertNodesIdentical_(
×
36
        lhsModel.LogicalNodes,
×
37
        rhsModel.LogicalNodes);
×
38

39
    // TODO: The rest
40
  }
×
41

42
  private static ModelRoot ParseModelFromBytes_(IReadOnlyTreeFile file) {
×
43
    var directory = file.AssertGetParent();
×
44
    return ReadContext.Create(f => directory
×
45
                                   .AssertGetExistingFile(f)
×
46
                                   .ReadAllBytes())
×
47
                      .ReadBinarySchema2(file.OpenRead());
×
48
  }
×
49

50
  private static void AssertAnimationsIdentical_(
51
      IReadOnlyList<Animation> lhsAnimations,
52
      IReadOnlyList<Animation> rhsAnimations) {
×
53
    Assert.AreEqual(lhsAnimations.Count, rhsAnimations.Count);
×
54
    foreach (var (lhsAnimation, rhsAnimation) in lhsAnimations.Zip(
×
55
                 rhsAnimations)) {
×
56
      Assert.AreEqual(lhsAnimation.Name, rhsAnimation.Name);
×
57
      var animationName = lhsAnimation.Name;
×
58

59
      AnnotatedException.Space(
×
60
          $"Found a change in animation {animationName}:\n",
×
61
          () => {
×
62
            Assert.AreEqual(lhsAnimation.Duration,
×
63
                            rhsAnimation.Duration,
×
64
                            animationName);
×
65

×
66
            var lhsChannels = lhsAnimation.Channels;
×
67
            var rhsChannels = rhsAnimation.Channels;
×
68
            Assert.AreEqual(lhsChannels.Count,
×
69
                            rhsChannels.Count,
×
70
                            animationName);
×
71
            foreach (var (lhsChannel, rhsChannel) in lhsChannels.Zip(
×
72
                         rhsChannels)) {
×
73
              Assert.AreEqual(lhsChannel.TargetNodePath,
×
74
                              rhsChannel.TargetNodePath,
×
75
                              animationName);
×
76

×
77
              switch (lhsChannel.TargetNodePath) {
×
78
                case PropertyPath.translation: {
×
79
                  AssertChannelsIdentical_(lhsChannel.GetTranslationSampler(),
×
80
                                           rhsChannel.GetTranslationSampler(),
×
81
                                           animationName);
×
82
                  break;
×
83
                }
×
84
                case PropertyPath.rotation: {
×
85
                  AssertChannelsIdentical_(lhsChannel.GetRotationSampler(),
×
86
                                           rhsChannel.GetRotationSampler(),
×
87
                                           animationName);
×
88
                  break;
×
89
                }
×
90
                case PropertyPath.scale: {
×
91
                  AssertChannelsIdentical_(lhsChannel.GetScaleSampler(),
×
92
                                           rhsChannel.GetScaleSampler(),
×
93
                                           animationName);
×
94
                  break;
×
95
                }
×
96
                default:
×
97
                  throw new NotImplementedException(
×
98
                      $"{nameof(lhsChannel.TargetNodePath)}: {lhsChannel.TargetNodePath}");
×
99
              }
×
100
            }
×
101
          });
×
102
    }
×
103
  }
×
104

105
  private static void AssertChannelsIdentical_<T>(
106
      IAnimationSampler<T> lhs,
107
      IAnimationSampler<T> rhs,
108
      string animationName) {
×
109
    Assert.AreEqual(lhs.InterpolationMode,
×
110
                    rhs.InterpolationMode,
×
111
                    animationName);
×
112

113
    switch (lhs.InterpolationMode) {
×
114
      case AnimationInterpolationMode.STEP:
115
      case AnimationInterpolationMode.LINEAR: {
×
116
        Asserts.SequenceEqual(lhs.GetLinearKeys(), rhs.GetLinearKeys());
×
117
        break;
×
118
      }
119
      case AnimationInterpolationMode.CUBICSPLINE: {
×
120
        Asserts.SequenceEqual(lhs.GetCubicKeys(), rhs.GetCubicKeys());
×
121
        break;
×
122
      }
123
      default: throw new NotImplementedException(nameof(lhs.InterpolationMode));
×
124
    }
125
  }
×
126

127
  private static void AssertMaterialsIdentical_(
128
      IReadOnlyList<Material> lhsMaterials,
129
      IReadOnlyList<Material> rhsMaterials) {
×
130
    Assert.AreEqual(lhsMaterials.Count, rhsMaterials.Count);
×
131

132
    foreach (var (lhsMaterial, rhsMaterial) in lhsMaterials.Zip(
×
133
                 rhsMaterials)) {
×
134
      Assert.AreEqual(lhsMaterial.Name, rhsMaterial.Name);
×
135
      var materialName = lhsMaterial.Name;
×
136

137
      // TODO: The rest
138
    }
×
139
  }
×
140

141
  private static void AssertSkinsIdentical_(
142
      IReadOnlyList<Skin> lhsSkins,
143
      IReadOnlyList<Skin> rhsSkins) {
×
144
    Assert.AreEqual(lhsSkins.Count, rhsSkins.Count);
×
145

146
    foreach (var (lhsSkin, rhsSkin) in lhsSkins.Zip(rhsSkins)) {
×
147
      Assert.AreEqual(lhsSkin.Name, rhsSkin.Name);
×
148
      var skinName = lhsSkin.Name;
×
149

150
      AnnotatedException.Space(
×
151
          $"Found a change in skin {skinName}:\n",
×
152
          () => {
×
153
            Assert.AreEqual(lhsSkin.InverseBindMatrices.Count,
×
154
                            rhsSkin.InverseBindMatrices.Count);
×
155
            foreach (var (lhsInverseBindMatrix, rhsInverseBindMatrix) in
×
156
                     lhsSkin.InverseBindMatrices.Zip(
×
157
                         rhsSkin.InverseBindMatrices)) {
×
158
              Asserts.Equal(lhsInverseBindMatrix,
×
159
                            rhsInverseBindMatrix,
×
160
                            skinName);
×
161
            }
×
162

×
163
            Assert.AreEqual(lhsSkin.Joints.Count, rhsSkin.Joints.Count);
×
164
            foreach (var (lhsJoint, rhsJoint) in lhsSkin.Joints.Zip(
×
165
                         rhsSkin.Joints)) {
×
166
              Asserts.Equal(lhsJoint.Name, rhsJoint.Name, skinName);
×
167
              var jointName = lhsJoint.Name;
×
168

×
169
              Asserts.Equal(lhsJoint.LocalMatrix,
×
170
                            rhsJoint.LocalMatrix,
×
171
                            jointName);
×
172
            }
×
173
          });
×
174
    }
×
175
  }
×
176

177
  private static void AssertMeshesIdentical_(
178
      IReadOnlyList<Mesh> lhsMeshes,
179
      IReadOnlyList<Mesh> rhsMeshes) {
×
180
    Assert.AreEqual(lhsMeshes.Count, rhsMeshes.Count);
×
181

182
    foreach (var (lhsMesh, rhsMesh) in lhsMeshes.Zip(rhsMeshes)) {
×
183
      Assert.AreEqual(lhsMesh.Name, rhsMesh.Name);
×
184

185
      AnnotatedException.Space(
×
186
          $"Found a change in mesh {lhsMesh.Name}:\n",
×
187
          () => {
×
188
            Assert.AreEqual(lhsMesh.Primitives.Count, rhsMesh.Primitives.Count);
×
189
            foreach (var (lhsPrimitive, rhsPrimitive) in lhsMesh.Primitives.Zip(
×
190
                         rhsMesh.Primitives)) {
×
191
              var lhsMaterial = lhsPrimitive.Material;
×
192
              var rhsMaterial = rhsPrimitive.Material;
×
193

×
194
              if (!lhsMaterial.Equals(rhsMaterial)) {
×
195
                Assert.AreEqual(lhsMaterial.Name, rhsMaterial.Name);
×
196
                Assert.AreEqual(lhsMaterial.Unlit, rhsMaterial.Unlit);
×
197
                Assert.AreEqual(lhsMaterial.Alpha, rhsMaterial.Alpha);
×
198
                Assert.AreEqual(lhsMaterial.AlphaCutoff, rhsMaterial.AlphaCutoff);
×
199
                Assert.AreEqual(lhsMaterial.DoubleSided, rhsMaterial.DoubleSided);
×
200

×
201
                var lhsDiffuseTexture = lhsMaterial.GetDiffuseTexture();
×
202
                var rhsDiffuseTexture = rhsMaterial.GetDiffuseTexture();
×
203

×
204
                var lhsSampler = lhsDiffuseTexture.Sampler;
×
205
                var rhsSampler = rhsDiffuseTexture.Sampler;
×
206

×
207
                Assert.AreEqual(lhsSampler.Name, rhsSampler.Name);
×
208
                Assert.AreEqual(lhsSampler.MagFilter, rhsSampler.MagFilter);
×
209
                Assert.AreEqual(lhsSampler.MinFilter, rhsSampler.MinFilter);
×
210
                Assert.AreEqual(lhsSampler.WrapS, rhsSampler.WrapS);
×
211
                Assert.AreEqual(lhsSampler.WrapT, rhsSampler.WrapT);
×
212
                Assert.AreEqual(lhsSampler.Extras, rhsSampler.Extras);
×
213
                foreach (var (lhsExtension, rhsExtension) in lhsSampler
×
214
                             .Extensions.Zip(rhsSampler.Extensions)) {
×
215
                  Assert.AreEqual(lhsExtension, rhsExtension);
×
216
                }
×
217
                Assert.AreEqual(lhsSampler, rhsSampler);
×
218
                Assert.AreEqual(lhsDiffuseTexture.PrimaryImage, rhsDiffuseTexture.PrimaryImage);
×
219
                Assert.AreEqual(lhsDiffuseTexture, rhsDiffuseTexture);
×
220

×
221
                Assert.AreEqual(lhsMaterial.Channels, rhsMaterial.Channels);
×
222

×
223
                Assert.Fail(
×
224
                    $"Found a change in material from {lhsMaterial} to {rhsMaterial}, but not sure where.");
×
225
              }
×
226

×
227
              Asserts.SequenceEqual(lhsPrimitive.IndexAccessor.AsIndicesArray(),
×
228
                                    rhsPrimitive.IndexAccessor
×
229
                                                .AsIndicesArray());
×
230
            }
×
231

×
232
            // TODO: The rest
×
233
          });
×
234
    }
×
235
  }
×
236

237
  private static void AssertNodesIdentical_(
238
      IReadOnlyList<Node> lhsNodes,
239
      IReadOnlyList<Node> rhsNodes) {
×
240
    Assert.AreEqual(lhsNodes.Count, rhsNodes.Count);
×
241

242
    foreach (var (lhsNode, rhsNode) in lhsNodes.Zip(rhsNodes)) {
×
243
      Assert.AreEqual(lhsNode.Name, rhsNode.Name);
×
244
      var nodeName = lhsNode.Name;
×
245

246
      Asserts.Equal(lhsNode.LocalMatrix, rhsNode.LocalMatrix, nodeName);
×
247
    }
×
248
  }
×
249
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc