<commit_before>//
//  Sequence.swift
//  SignificantSpices
//
//  Created by <NAME> on 8/11/17.
//  Copyright © 2017 resmio. All rights reserved.
//

import XCTest
import SignificantSpices.Swift


class SequenceGroupedByTests: XCTestCase {
    func testSequenceGroupedBy() {
        
    }
}<commit_msg>Add test for groupedBy()<commit_after>//
//  Sequence.swift
//  SignificantSpices
//
//  Created by <NAME> on 8/11/17.
//  Copyright © 2017 resmio. All rights reserved.
//

import XCTest
import SignificantSpices.Swift


// Helper Types
private class Foo {
    init(_ bar: Int) { self.bar = bar }
    private(set) var bar: Int
}


class SequenceGroupedByTests: XCTestCase {
    func testSequenceGroupedBy() {
        let aBar: Int = 0
        let bBar: Int = 1
        let cBar: Int = 2
        let dBar: Int = 3
        let eBar: Int = 4
        
        let a: Foo = Foo(aBar)
        let b: Foo = Foo(bBar)
        let c: Foo = Foo(cBar)
        let d: Foo = Foo(dBar)
        let e: Foo = Foo(eBar)
        
        let seq: [Foo] = [e, d, a, b, a, d, c, c, e, c, a, b, a, d, c, e, b, b, e, d]
        
        let groupedSeq: [Int : [Foo]] = seq.groupedBy({ $0.bar })
        
        XCTAssertEqual(groupedSeq.count, 5)
        
        guard let allAs: [Foo] = groupedSeq[aBar] else {
            XCTFail("Grouped Sequence does not contain key \(aBar)")
            return
        }
        
        XCTAssertEqual(allAs.map({ $0.bar }), [aBar, aBar, aBar, aBar])
        
        guard let allBs: [Foo] = groupedSeq[bBar] else {
            XCTFail("Grouped Sequence does not contain key \(bBar)")
            return
        }
        
        XCTAssertEqual(allBs.map({ $0.bar }), [bBar, bBar, bBar, bBar])
        
        guard let allCs: [Foo] = groupedSeq[cBar] else {
            XCTFail("Grouped Sequence does not contain key \(cBar)")
            return
        }
        
        XCTAssertEqual(allCs.map({ $0.bar }), [cBar, cBar, cBar, cBar])
        
        guard let allDs: [Foo] = groupedSeq[dBar] else {
            XCTFail("Grouped Sequence does not contain key \(dBar)")
            return
        }
        
        XCTAssertEqual(allDs.map({ $0.bar }), [dBar, dBar, dBar, dBar])
        
        guard let allEs: [Foo] = groupedSeq[eBar] else {
            XCTFail("Grouped Sequence does not contain key \(eBar)")
            return
        }
        
        XCTAssertEqual(allEs.map({ $0.bar }), [eBar, eBar, eBar, eBar])
    }
}
{'fraction_non_alphanumeric': 0.12479674796747968, 'fraction_numerical': 0.012195121951219513, 'mean_word_length': 1.8061573546180159, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2647902', 'n_tokens_mistral': 900, 'n_tokens_neox': 830, 'n_words': 236}