<commit_before>//
//  LexisWordTests.swift
//  LexisDatabase
//
//  Created by <NAME> on 9/3/16.
//  Copyright © 2016 RedRoma, Inc. All rights reserved.
//

import Foundation
import XCTest
@testable import LexisDatabase

class WordTypeTests: XCTestCase
{
    
    var left: WordType!
    var right: WordType!
    
    override func setUp()
    {
        left = Data.randomWordType
        right = Data.randomWordType
    }
    
    func testEquals()
    {
        right = left
        XCTAssertTrue(right == left)
    }
    
    
    func testEqualsWhenDifferent()
    {
        while right == left
        {
            right = Data.randomWordType
        }
        
        XCTAssertFalse(right == left)
    }
    
    
    func testHashCode()
    {
        XCTAssertEqual(left.hashValue, right.hashValue)
    }
    
    
}

class DefinitionTests: XCTestCase
{
    
    private var terms: [String] = arrayOfSize(valueGenerator: alphabeticalStringOfAnySize)
    
    private var definition: LexisDefinition!
    
    override func setUp()
    {
        definition = LexisDefinition(terms: terms)
    }
    
    func testEquatable()
    {
        let secondDefinition = LexisDefinition(terms: terms)
        XCTAssertTrue(secondDefinition == definition)
        XCTAssertEqual(secondDefinition, definition)
    }
    
    func testEquatableWhenDifferent()
    {
        let otherTerms = arrayOfSize(valueGenerator: alphabeticalStringOfAnySize)
        let otherDefinition = LexisDefinition(terms: otherTerms)
        
        XCTAssertFalse(otherDefinition == definition)
        XCTAssertNotEqual(otherDefinition, definition)
    }
    
    func testHashCodeOfSameObject()
    {
        let first = definition.hashValue
        let second = definition.hashValue
        XCTAssertEqual(first, second)
    }
    
    func testHashCodeOfDifferentDefinitions()
    {
        let otherTerms = arrayOfSize(valueGenerator: alphabeticalStringOfAnySize)
        let otherDefinition = LexisDefinition(terms: otherTerms)
        
        let first = definition.hashValue
        let second = otherDefinition.hashValue
        XCTAssertNotEqual(first, second)
    }
    
    func testHashCodeOfDifferentInstanceButSameObject()
    {
        let copy = LexisDefinition(terms: terms)
        
        let first = definition.hashValue
        let second = copy.hashValue
        XCTAssertEqual(first, second)
        XCTAssertTrue(first == second)
    }
}

class LexisWordTests: XCTestCase
{
    
    private var forms: [String] = []
    private var wordType: WordType! = nil
    private var definitions: [LexisDefinition] = []
    
    
    private var randomForms: [String] { return arrayOfSize(valueGenerator: alphabeticalStringOfAnySize) }
    private var randomDefintions: [LexisDefinition]
    {
        let generator: () -> (LexisDefinition) =
        {
            let terms = self.randomForms
            return LexisDefinition(terms: terms)
        }
        
        return arrayOfSize(valueGenerator: generator)
    }
    
    private var word: LexisWord! = nil
    
    override func setUp()
    {
        forms = randomForms
        wordType = Data.randomWordType
        definitions = randomDefintions
        
        word = LexisWord(forms: forms, wordType: wordType, definitions: definitions)
    }
    
    
    func testEquality()
    {
        let shallowCopy = word
        XCTAssertEqual(shallowCopy, word)
        XCTAssertTrue(shallowCopy == word)
        
        let deepCopy = LexisWord(forms: forms, wordType: wordType, definitions: definitions)
        XCTAssertEqual(deepCopy, word)
        XCTAssertTrue(deepCopy == word)
        
    }
    
    func testEqualityWhenDifferent()
    {
        let differentForms = LexisWord(forms: randomForms, wordType: wordType, definitions: definitions)
        XCTAssertTrue(differentForms != word)
        
        let differentWordType = LexisWord(forms: forms, wordType: Data.randomWordType, definitions: definitions)
        XCTAssertTrue(differentWordType != word)
        
        let differentDefinitions = LexisWord(forms: forms, wordType: wordType, definitions: randomDefintions)
        XCTAssertTrue(differentDefinitions != word)
        
    }
}<commit_msg>Adds Unit Tests<commit_after>//
//  LexisWordTests.swift
//  LexisDatabase
//
//  Created by <NAME> on 9/3/16.
//  Copyright © 2016 RedRoma, Inc. All rights reserved.
//

import Foundation
import XCTest
@testable import LexisDatabase

class WordTypeTests: XCTestCase
{
    
    var left: WordType!
    var right: WordType!
    
    override func setUp()
    {
        left = Data.randomWordType
        right = Data.randomWordType
    }
    
    func testEquals()
    {
        right = left
        XCTAssertTrue(right == left)
    }
    
    
    func testEqualsWhenDifferent()
    {
        while right == left
        {
            right = Data.randomWordType
        }
        
        XCTAssertFalse(right == left)
    }
    
    
    func testHashCode()
    {
        XCTAssertEqual(left.hashValue, right.hashValue)
    }
    
    
}

class DefinitionTests: XCTestCase
{
    
    private var terms: [String] = arrayOfSize(valueGenerator: alphabeticalStringOfAnySize)
    
    private var definition: LexisDefinition!
    
    override func setUp()
    {
        definition = LexisDefinition(terms: terms)
    }
    
    func testEquatable()
    {
        let secondDefinition = LexisDefinition(terms: terms)
        XCTAssertTrue(secondDefinition == definition)
        XCTAssertEqual(secondDefinition, definition)
    }
    
    func testEquatableWhenDifferent()
    {
        let otherTerms = arrayOfSize(valueGenerator: alphabeticalStringOfAnySize)
        let otherDefinition = LexisDefinition(terms: otherTerms)
        
        XCTAssertFalse(otherDefinition == definition)
        XCTAssertNotEqual(otherDefinition, definition)
    }
    
    func testHashCodeOfSameObject()
    {
        let first = definition.hashValue
        let second = definition.hashValue
        XCTAssertEqual(first, second)
    }
    
    func testHashCodeOfDifferentDefinitions()
    {
        let otherTerms = arrayOfSize(valueGenerator: alphabeticalStringOfAnySize)
        let otherDefinition = LexisDefinition(terms: otherTerms)
        
        let first = definition.hashValue
        let second = otherDefinition.hashValue
        XCTAssertNotEqual(first, second)
    }
    
    func testHashCodeOfDifferentInstanceButSameObject()
    {
        let copy = LexisDefinition(terms: terms)
        
        let first = definition.hashValue
        let second = copy.hashValue
        XCTAssertEqual(first, second)
        XCTAssertTrue(first == second)
    }
}

class LexisWordTests: XCTestCase
{
    
    private var forms: [String] = []
    private var wordType: WordType! = nil
    private var definitions: [LexisDefinition] = []
    
    
    private var randomForms: [String] { return arrayOfSize(valueGenerator: alphabeticalStringOfAnySize) }
    private var randomDefintions: [LexisDefinition]
    {
        let generator: () -> (LexisDefinition) =
        {
            let terms = self.randomForms
            return LexisDefinition(terms: terms)
        }
        
        return arrayOfSize(valueGenerator: generator)
    }
    
    private var word: LexisWord! = nil
    
    override func setUp()
    {
        forms = randomForms
        wordType = Data.randomWordType
        definitions = randomDefintions
        
        word = LexisWord(forms: forms, wordType: wordType, definitions: definitions)
    }
    
    
    func testEquality()
    {
        let shallowCopy = word
        XCTAssertEqual(shallowCopy, word)
        XCTAssertTrue(shallowCopy == word)
        
        let deepCopy = LexisWord(forms: forms, wordType: wordType, definitions: definitions)
        XCTAssertEqual(deepCopy, word)
        XCTAssertTrue(deepCopy == word)
        
    }
    
    func testEqualityWhenDifferent()
    {
        let differentForms = LexisWord(forms: randomForms, wordType: wordType, definitions: definitions)
        XCTAssertTrue(differentForms != word)
        
        let differentWordType = LexisWord(forms: forms, wordType: Data.randomWordType, definitions: definitions)
        XCTAssertTrue(differentWordType != word)
        
        let differentDefinitions = LexisWord(forms: forms, wordType: wordType, definitions: randomDefintions)
        XCTAssertTrue(differentDefinitions != word)
        
    }
    
    func testHashCodeWhenSame()
    {
        let copy = LexisWord(forms: forms, wordType: wordType, definitions: definitions)
        let first = word.hashValue
        let second = copy.hashValue
        XCTAssertEqual(first, second)
    }
    
    func testHashCodeWhenDifferent()
    {
        let other = LexisWord(forms: randomForms, wordType: Data.randomWordType, definitions: randomDefintions)
        let first = word.hashValue
        let second = other.hashValue
        
        XCTAssertNotEqual(first, second)
    }
}
{'fraction_non_alphanumeric': 0.07423483583750695, 'fraction_numerical': 0.0017807456872565386, 'mean_word_length': 2.3567426223384387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5995704', 'n_tokens_mistral': 2541, 'n_tokens_neox': 2478, 'n_words': 554}