<commit_before>//
//  EZArrayExtensionsTests.swift
//  EZSwiftExtensions
//
//  Created by <NAME> on 28/01/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import XCTest
import EZSwiftExtensions

class EZSwiftExtensionsTestsArray: XCTestCase {
    var numberArray: [Int] = []

    override func setUp() {
        super.setUp()
        //[0, 1, 2, 3, 4, 5, 1]
        numberArray = [Int](0...5)
        numberArray.append(1)
    }

    func testIndexesOf() {
        var indexes = numberArray.indexesOf(1)
        XCTAssertEqual(indexes, [1, 6])

        indexes = numberArray.indexesOf(12345)
        XCTAssertEqual(indexes, [])
    }

    func testRemoveObject() {
        let copyArray = numberArray
        numberArray.removeObject(12345)
        XCTAssertEqual(numberArray, copyArray)

        let compareArray = [0, 2, 3, 4, 5, 1]
        numberArray.removeObject(1)
        XCTAssertEqual(numberArray, compareArray)
    }

    func testRemoveObjects() {
        let copyArray = numberArray
        numberArray.removeObjects(12345)
        XCTAssertEqual(numberArray, copyArray)

        let compareArray = [0, 2, 3, 4, 5]
        numberArray.removeObjects(1)
        XCTAssertEqual(numberArray, compareArray)
    }

    func testContainsInstanceOf() {
        XCTAssertFalse(numberArray.containsInstanceOf("a"))
        XCTAssertFalse(numberArray.containsInstanceOf(12.22))
        XCTAssertTrue(numberArray.containsInstanceOf(46378))
    }

    func testContainsArray() {
        let array = [Int](2...4)
        XCTAssertTrue(numberArray.containsArray(array))
    }

    func testRandom() {
        XCTAssertNotNil(numberArray.random())
        XCTAssertNil([].random())
    }

    func testTestAll() {
        XCTAssertTrue(numberArray.testAll { $0 < 10 })
    }

    func testTestIfAllIs() {
        let array1 = [true, true, true]
        let array2 = [false, false]
        let array3 = [true, false]

        XCTAssertEqual(array1.testIfAllIs(true), true)
        XCTAssertEqual(array2.testIfAllIs(true), false)
        XCTAssertEqual(array2.testIfAllIs(false), true)
        XCTAssertEqual(array3.testIfAllIs(true), false)
        XCTAssertEqual(array3.testIfAllIs(false), false)
        XCTAssertEqual(numberArray.testIfAllIs(true), false)
    }

    func testGet() {
        XCTAssertNotNil(numberArray.get(1))
        XCTAssertNil(numberArray.get(10))
    }

    func testReverseIndex() {
        let array = [Int](0...5)
        XCTAssertEqual(array.reverseIndex(0), 5)
        XCTAssertEqual(array.reverseIndex(2), 3)
    }

    func testTakeMax() {
        XCTAssertEqual(numberArray.takeMax(2).count, 2)
    }

    func testEach() {
        var sameArray: [Int] = []
        numberArray.each { sameArray.append($0) }
        XCTAssertEqual(numberArray, sameArray)

        var indexArray: [Int] = []
        numberArray.each { indexArray.append($0.0) }
        XCTAssertEqual(indexArray, [Int](0..<numberArray.count))
    }

    func testMapFilter() {
        let filtered = numberArray.mapFilter { number -> String? in
            return number == 1 ? String(number) : nil
        }

        XCTAssertEqual(filtered.count, 2)
    }

    func testUnion() {
        let a = [Int](0...2), b = [Int](3...5), c = [Int](6...8)
        let union = a.union(b, c)

        XCTAssertEqual(union, [Int](0...8))
    }

    func testIntersection() {
        let a = [Int](0...8), b = [Int](3...4), c = [Int](1...6)
        let intersection = a.intersection(b, c)

        XCTAssertEqual(intersection, [3, 4])
    }

    func testDifference() {
        let a = [Int](0...8), b = [Int](3...4), c = [Int](1...2)
        let difference = a.difference(b, c)

        XCTAssertEqual(difference, [0, 5, 6, 7, 8])
    }

    func testOptionalEquatable() {
        let a: [Int]? = [1, 2, 3]
        let b: [Int]? = [1, 2, 3]
        let c: [Int]? = nil

        XCTAssertTrue(a == b)
        XCTAssertFalse(a == c)
    }
}<commit_msg>Added testShuffle()<commit_after>//
//  EZArrayExtensionsTests.swift
//  EZSwiftExtensions
//
//  Created by <NAME> on 28/01/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import XCTest
import EZSwiftExtensions

class EZSwiftExtensionsTestsArray: XCTestCase {
    var numberArray: [Int] = []

    override func setUp() {
        super.setUp()
        //[0, 1, 2, 3, 4, 5, 1]
        numberArray = [Int](0...5)
        numberArray.append(1)
    }

    func testIndexesOf() {
        var indexes = numberArray.indexesOf(1)
        XCTAssertEqual(indexes, [1, 6])

        indexes = numberArray.indexesOf(12345)
        XCTAssertEqual(indexes, [])
    }

    func testRemoveObject() {
        let copyArray = numberArray
        numberArray.removeObject(12345)
        XCTAssertEqual(numberArray, copyArray)

        let compareArray = [0, 2, 3, 4, 5, 1]
        numberArray.removeObject(1)
        XCTAssertEqual(numberArray, compareArray)
    }

    func testRemoveObjects() {
        let copyArray = numberArray
        numberArray.removeObjects(12345)
        XCTAssertEqual(numberArray, copyArray)

        let compareArray = [0, 2, 3, 4, 5]
        numberArray.removeObjects(1)
        XCTAssertEqual(numberArray, compareArray)
    }

    func testContainsInstanceOf() {
        XCTAssertFalse(numberArray.containsInstanceOf("a"))
        XCTAssertFalse(numberArray.containsInstanceOf(12.22))
        XCTAssertTrue(numberArray.containsInstanceOf(46378))
    }

    func testContainsArray() {
        let array = [Int](2...4)
        XCTAssertTrue(numberArray.containsArray(array))
    }

    func testRandom() {
        XCTAssertNotNil(numberArray.random())
        XCTAssertNil([].random())
    }

    func testTestAll() {
        XCTAssertTrue(numberArray.testAll { $0 < 10 })
    }

    func testTestIfAllIs() {
        let array1 = [true, true, true]
        let array2 = [false, false]
        let array3 = [true, false]

        XCTAssertEqual(array1.testIfAllIs(true), true)
        XCTAssertEqual(array2.testIfAllIs(true), false)
        XCTAssertEqual(array2.testIfAllIs(false), true)
        XCTAssertEqual(array3.testIfAllIs(true), false)
        XCTAssertEqual(array3.testIfAllIs(false), false)
        XCTAssertEqual(numberArray.testIfAllIs(true), false)
    }

    func testGet() {
        XCTAssertNotNil(numberArray.get(1))
        XCTAssertNil(numberArray.get(10))
    }

    func testReverseIndex() {
        let array = [Int](0...5)
        XCTAssertEqual(array.reverseIndex(0), 5)
        XCTAssertEqual(array.reverseIndex(2), 3)
    }

    func testTakeMax() {
        XCTAssertEqual(numberArray.takeMax(2).count, 2)
    }

    func testEach() {
        var sameArray: [Int] = []
        numberArray.each { sameArray.append($0) }
        XCTAssertEqual(numberArray, sameArray)

        var indexArray: [Int] = []
        numberArray.each { indexArray.append($0.0) }
        XCTAssertEqual(indexArray, [Int](0..<numberArray.count))
    }

    func testMapFilter() {
        let filtered = numberArray.mapFilter { number -> String? in
            return number == 1 ? String(number) : nil
        }

        XCTAssertEqual(filtered.count, 2)
    }

    func testUnion() {
        let a = [Int](0...2), b = [Int](3...5), c = [Int](6...8)
        let union = a.union(b, c)

        XCTAssertEqual(union, [Int](0...8))
    }

    func testIntersection() {
        let a = [Int](0...8), b = [Int](3...4), c = [Int](1...6)
        let intersection = a.intersection(b, c)

        XCTAssertEqual(intersection, [3, 4])
    }

    func testDifference() {
        let a = [Int](0...8), b = [Int](3...4), c = [Int](1...2)
        let difference = a.difference(b, c)

        XCTAssertEqual(difference, [0, 5, 6, 7, 8])
    }

    func testOptionalEquatable() {
        let a: [Int]? = [1, 2, 3]
        let b: [Int]? = [1, 2, 3]
        let c: [Int]? = nil

        XCTAssertTrue(a == b)
        XCTAssertFalse(a == c)
    }
    
    func testShuffle() {
        let copyArray = numberArray
        
        numberArray.shuffle()
        
        XCTAssertNotNil(numberArray)
        XCTAssertEqual(numberArray.count, copyArray.count)
        
        for e in copyArray {
            if let i = numberArray.indexOf(e) {
                numberArray.removeAtIndex(i)
            }
        }
        XCTAssertEqual(numberArray, [])
    }
}
{'fraction_non_alphanumeric': 0.13308442731542816, 'fraction_numerical': 0.029627845357099843, 'mean_word_length': 2.301789264413519, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4623704', 'n_tokens_mistral': 2878, 'n_tokens_neox': 2684, 'n_words': 528}