<commit_before>/**
 * <NAME> - http://taewon.de - @hataewon
 * See LICENSE
 */

import XCTest
import Nimble

class FileUtilsTest: XCTestCase {

  var fileUtilsRsrcUrl = URL(fileURLWithPath: "/")
  var a1Dir = URL(fileURLWithPath: "/")

  override func setUp() {
    fileUtilsRsrcUrl = Bundle.init(for: type(of: self)).url(forResource: "FileUtilsTest", withExtension: "")!
    a1Dir = fileUtilsRsrcUrl.appendingPathComponent("a1")
  }

  func testCommonParentOneDirUrl() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
    ]

    expect(FileUtils.commonParent(ofUrls: urls)).to(equal(a1Dir))
  }

  func testCommonParentOneFileUrl() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
    ]

    expect(FileUtils.commonParent(ofUrls: urls)).to(equal(a1Dir))
  }

  func testCommonParentEmptyParams() {
    expect(FileUtils.commonParent(ofUrls: []) as URL).to(equal(URL(fileURLWithPath: "/", isDirectory: true)))
  }

  func testCommonParent1() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
    ]

    expect(FileUtils.commonParent(ofUrls: urls)).to(equal(a1Dir))
  }

  func testCommonParent2() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
    ]

    expect(FileUtils.commonParent(ofUrls: urls)).to(equal(a1Dir))
  }

  func testBug1() {
    let paths = [
      fileUtilsRsrcUrl.appendingPathComponent("Downloads/test2/some/nginx.config"),
      fileUtilsRsrcUrl.appendingPathComponent(".Trash/nginx.config")
    ]
    expect(FileUtils.commonParent(ofUrls: paths)).to(equal(fileUtilsRsrcUrl))
  }

  func testBug2() {
    let paths = [
      fileUtilsRsrcUrl.appendingPathComponent("Downloads/test2/some/nginx.config"),
      fileUtilsRsrcUrl.appendingPathComponent(".Trash/nginx.config/de/nginx.config")
    ]
    expect(FileUtils.commonParent(ofUrls: paths)).to(equal(fileUtilsRsrcUrl))
  }

  func testCommonParent3() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("b1/b1-file1"),
    ]

    expect(FileUtils.commonParent(ofUrls: urls)).to(equal(fileUtilsRsrcUrl))
  }

  func testCommonParent4() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("b1"),
    ]

    expect(FileUtils.commonParent(ofUrls: urls)).to(equal(fileUtilsRsrcUrl))
  }

  func testCommonParent5() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2"),
    ]

    expect(FileUtils.commonParent(ofUrls: urls)).to(equal(a1Dir))
  }
}
<commit_msg>GH-308 Fix tests<commit_after>/**
 * <NAME> - http://taewon.de - @hataewon
 * See LICENSE
 */

import XCTest
import Nimble

class FileUtilsTest: XCTestCase {

  var fileUtilsRsrcUrl = URL(fileURLWithPath: "/")
  var a1Dir = URL(fileURLWithPath: "/")

  override func setUp() {
    fileUtilsRsrcUrl = Bundle.init(for: type(of: self)).url(forResource: "FileUtilsTest", withExtension: "")!
    a1Dir = fileUtilsRsrcUrl.appendingPathComponent("a1")
  }

  func testCommonParentOneDirUrl() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
    ]

    expect(FileUtils.commonParent(of: urls)).to(equal(a1Dir))
  }

  func testCommonParentOneFileUrl() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
    ]

    expect(FileUtils.commonParent(of: urls)).to(equal(a1Dir))
  }

  func testCommonParentEmptyParams() {
    expect(FileUtils.commonParent(of: []) as URL).to(equal(URL(fileURLWithPath: "/", isDirectory: true)))
  }

  func testCommonParent1() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
    ]

    expect(FileUtils.commonParent(of: urls)).to(equal(a1Dir))
  }

  func testCommonParent2() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
    ]

    expect(FileUtils.commonParent(of: urls)).to(equal(a1Dir))
  }

  func testBug1() {
    let paths = [
      fileUtilsRsrcUrl.appendingPathComponent("Downloads/test2/some/nginx.config"),
      fileUtilsRsrcUrl.appendingPathComponent(".Trash/nginx.config")
    ]
    expect(FileUtils.commonParent(of: paths)).to(equal(fileUtilsRsrcUrl))
  }

  func testBug2() {
    let paths = [
      fileUtilsRsrcUrl.appendingPathComponent("Downloads/test2/some/nginx.config"),
      fileUtilsRsrcUrl.appendingPathComponent(".Trash/nginx.config/de/nginx.config")
    ]
    expect(FileUtils.commonParent(of: paths)).to(equal(fileUtilsRsrcUrl))
  }

  func testCommonParent3() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("b1/b1-file1"),
    ]

    expect(FileUtils.commonParent(of: urls)).to(equal(fileUtilsRsrcUrl))
  }

  func testCommonParent4() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("b1"),
    ]

    expect(FileUtils.commonParent(of: urls)).to(equal(fileUtilsRsrcUrl))
  }

  func testCommonParent5() {
    let urls = [
      fileUtilsRsrcUrl.appendingPathComponent("a1/a1-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2/a1-a2-file1"),
      fileUtilsRsrcUrl.appendingPathComponent("a1/a2"),
    ]

    expect(FileUtils.commonParent(of: urls)).to(equal(a1Dir))
  }
}

{'fraction_non_alphanumeric': 0.13681868743047831, 'fraction_numerical': 0.02145240743683458, 'mean_word_length': 4.184514003294893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6692321', 'n_tokens_mistral': 2274, 'n_tokens_neox': 2224, 'n_words': 228}