<commit_before>//----------------------------------------------------------------------------//
//
// Copyright 2017 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------//

import CoreLocation
import Foundation
import HillListsBackupLibrary
import XCTest

/// Tests of the public API of the `BackupImporter` type.
class BackupImporterTests: XCTestCase {
  /// Returns the URL for a resource bundled with this test case.
  ///
  /// The runtime environment is taken into account since this differs between
  /// test cases run from the command line using `swift test` and test cases run
  /// from an IDE like AppCode or Xcode.
  ///
  /// - Parameters:
  ///   - forResource: the name of the resource to be found.
  ///   - withExtension: an optional resource name extension (minus any leading period).
  private func getBundledResourceURL(forResource resourceStem: String, withExtension resourceExtension: String?) -> URL? {
    if XCTestCase.isAssumedRunningFromCommandLine() {
      let resourceName: String

      if let resourceExtension = resourceExtension {
        resourceName = resourceStem.appending(".").appending(resourceExtension)
      } else {
        resourceName = resourceStem
      }

      // The Swift Package manager doesn't currently have support for bundling
      // and locating test resources so we have to resort to a bit of a hack
      // based on the observed directory structure of a project
      //
      // See feature request [SR-4725](https://bugs.swift.org/browse/SR-4725)
      //
      return NSURL.fileURL(
              withPathComponents: [
                Bundle(for: BackupImporterTests.self).bundlePath,
                "..",
                "..",
                "..",
                "Tests",
                "HillListsBackupLibraryTests",
                "Data",
                resourceName
              ])
    } else {
      return Bundle(for: type(of: self))
              .url(forResource: resourceStem, withExtension: resourceExtension, subdirectory: "Data")
    }
  }

  //------------------------------------------------------------------------------------------------------------------//<commit_msg>Account for changed build output directory structure<commit_after>//----------------------------------------------------------------------------//
//
// Copyright 2017 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------//

import CoreLocation
import Foundation
import HillListsBackupLibrary
import XCTest

/// Tests of the public API of the `BackupImporter` type.
class BackupImporterTests: XCTestCase {
  /// Returns the URL for a resource bundled with this test case.
  ///
  /// The runtime environment is taken into account since this differs between
  /// test cases run from the command line using `swift test` and test cases run
  /// from an IDE like AppCode or Xcode.
  ///
  /// - Parameters:
  ///   - forResource: the name of the resource to be found.
  ///   - withExtension: an optional resource name extension (minus any leading period).
  private func getBundledResourceURL(forResource resourceStem: String, withExtension resourceExtension: String?) -> URL? {
    if XCTestCase.isAssumedRunningFromCommandLine() {
      let resourceName: String

      if let resourceExtension = resourceExtension {
        resourceName = resourceStem.appending(".").appending(resourceExtension)
      } else {
        resourceName = resourceStem
      }

      // The Swift Package manager doesn't currently have support for bundling
      // and locating test resources so we have to resort to a bit of a hack
      // based on the observed directory structure of a project
      //
      // See feature request [SR-4725](https://bugs.swift.org/browse/SR-4725)
      //
      return NSURL.fileURL(
              withPathComponents: [
                Bundle(for: BackupImporterTests.self).bundlePath,
                "..",
                "..",
                "..",
                "..",
                "Tests",
                "HillListsBackupLibraryTests",
                "Data",
                resourceName
              ])
    } else {
      return Bundle(for: type(of: self))
              .url(forResource: resourceStem, withExtension: resourceExtension, subdirectory: "Data")
    }
  }

  //------------------------------------------------------------------------------------------------------------------//
{'fraction_non_alphanumeric': 0.1802336028751123, 'fraction_numerical': 0.005750224618149146, 'mean_word_length': 1.744575936883629, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6034331', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1250, 'n_words': 498}