Repository: airbnb/lottie-ios
File: Tests/AnimationKeypathTests.swift (Swift)

Code before:
    snapshotHierarchyKeypaths(
      animationName: "Switch",
      configuration: LottieConfiguration(renderingEngine: .mainThread))
  }

  func testCoreAnimationEngineKeypathLogging() {
    snapshotHierarchyKeypaths(
      animationName: "Switch",
      configuration: LottieConfiguration(renderingEngine: .coreAnimation))

    snapshotHierarchyKeypaths(
      animationName: "Issues/issue_1664",
      configuration: LottieConfiguration(renderingEngine: .coreAnimation))
  }

  /// The Core Animation engine supports a subset of the keypaths supported by the Main Thread engine.
  /// All keypaths that are supported in the Core Animation engine should also be supported by the Main Thread engine.
  func testCoreAnimationEngineKeypathCompatibility() {
    let mainThreadKeypaths = Set(hierarchyKeypaths(animationName: "Switch", configuration: .init(renderingEngine: .mainThread)))
    let coreAnimationKeypaths = hierarchyKeypaths(animationName: "Switch", configuration: .init(renderingEngine: .coreAnimation))

    for coreAnimationKeypath in coreAnimationKeypaths {
      XCTAssert(
        mainThreadKeypaths.contains(coreAnimationKeypath),
        """
        \(coreAnimationKeypath) from Core Animation rendering engine
        is not supported in Main Thread rendering engine
        """)
    }
  }

  // MARK: Private

  private func snapshotHierarchyKeypaths(
    animationName: String,
    configuration: LottieConfiguration,
    function: String = #function,
    line: UInt = #line)
  {
    let hierarchyKeypaths = hierarchyKeypaths(animationName: animationName, configuration: configuration)

    assertSnapshot(
      matching: hierarchyKeypaths.sorted().joined(separator: "\n"),
      as: .description,
      named: animationName,
      testName: function,
      line: line)
  }

  private func hierarchyKeypaths(animationName: String, configuration: LottieConfiguration) -> [String] {
    var printedMessages = [String]()

Review comment (suggestion):
nit: You can add a `\` to ensure that a newline isn't added between the lines of the string constructed by a multiline string literal
```suggestion
        \(coreAnimationKeypath) from Core Animation rendering engine \
```

Code after:
    snapshotHierarchyKeypaths(
      animationName: "Switch",
      configuration: LottieConfiguration(renderingEngine: .mainThread))
  }

  func testCoreAnimationEngineKeypathLogging() {
    snapshotHierarchyKeypaths(
      animationName: "Switch",
      configuration: LottieConfiguration(renderingEngine: .coreAnimation))

    snapshotHierarchyKeypaths(
      animationName: "Issues/issue_1664",
      configuration: LottieConfiguration(renderingEngine: .coreAnimation))
  }

  /// The Core Animation engine supports a subset of the keypaths supported by the Main Thread engine.
  /// All keypaths that are supported in the Core Animation engine should also be supported by the Main Thread engine.
  func testCoreAnimationEngineKeypathCompatibility() {
    let mainThreadKeypaths = Set(hierarchyKeypaths(animationName: "Switch", configuration: .init(renderingEngine: .mainThread)))
    let coreAnimationKeypaths = hierarchyKeypaths(animationName: "Switch", configuration: .init(renderingEngine: .coreAnimation))

    for coreAnimationKeypath in coreAnimationKeypaths {
      XCTAssert(
        mainThreadKeypaths.contains(coreAnimationKeypath),
        """
        \(coreAnimationKeypath) from Core Animation rendering engine \
        is not supported in Main Thread rendering engine
        """)
    }
  }

  // MARK: Private

  private func snapshotHierarchyKeypaths(
    animationName: String,
    configuration: LottieConfiguration,
    function: String = #function,
    line: UInt = #line)
  {
    let hierarchyKeypaths = hierarchyKeypaths(animationName: animationName, configuration: configuration)

    assertSnapshot(
      matching: hierarchyKeypaths.sorted().joined(separator: "\n"),
      as: .description,
      named: animationName,
      testName: function,
      line: line)
  }

  private func hierarchyKeypaths(animationName: String, configuration: LottieConfiguration) -> [String] {
    var printedMessages = [String]()