<commit_before>//
//  ComparableValidatorTests.swift
//  SwiftValidation
//
//  Created by Jon on 02/06/2016.
//  Copyright © 2016 joncotton. All rights reserved.
//

import XCTest
@testable import SwiftValidation

class ComparableValidatorTests: XCTestCase {

    func test_comparable_validator_is_valid_returns_true_for_value_higher_than_minimum_bounds_when_testing_for_minimum_value() {
        let comparableValidator = ComparableValidator.minimumValue(10)
        
        guard let result = try? comparableValidator.isValid(20) else {
            XCTFail("Expected minimum value test to pass when testing higher value than minimum bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
    func test_comparable_validator_is_valid_returns_true_for_value_equal_to_minimum_bounds_when_testing_for_minimum_value() {
        let comparableValidator = ComparableValidator.minimumValue(10)
        
        guard let result = try? comparableValidator.isValid(10) else {
            XCTFail("Expected minimum value test to pass when testing equal value to minimum bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
    func test_comparable_validator_throws_is_below_minimum_bounds_error_for_value_below_minimum_bounds_when_testing_for_minimum_value() {
        let comparableValidator = ComparableValidator.minimumValue(10)
        
        XCTAssertThrowsError(try comparableValidator.isValid(5)) { error in
            guard let comparableValidationError = error as? ComparableValidationError<Int> else {
                XCTFail("Unexpected error type thrown by ComparableValidator on failure")
                return
            }
            
            switch comparableValidationError {
            case .valueIsBelowMinimumBounds(let min):
                XCTAssertEqual(min, 10)
            default:
                XCTFail("Unexpected ComparableValidationError type thrown by ComparableValidator on failure")
            }
        }
    }
    
    func test_comparable_validator_is_valid_returns_true_for_value_lower_than_maximum_bounds_when_testing_for_maximum_value() {
        let comparableValidator = ComparableValidator.maximumValue(10)
        
        guard let result = try? comparableValidator.isValid(5) else {
            XCTFail("Expected maximum value test to pass when testing higher value than maximum bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
    func test_comparable_validator_is_valid_returns_true_for_value_equal_to_maximum_bounds_when_testing_for_maximum_value() {
        let comparableValidator = ComparableValidator.maximumValue(10)
        
        guard let result = try? comparableValidator.isValid(10) else {
            XCTFail("Expected maximum value test to pass when testing equal value to maximum bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
    func test_comparable_validator_throws_is_above_maximum_bounds_error_for_value_above_maximum_bounds_when_testing_for_maximum_value() {
        let comparableValidator = ComparableValidator.maximumValue(10)
        
        XCTAssertThrowsError(try comparableValidator.isValid(20)) { error in
            guard let comparableValidationError = error as? ComparableValidationError<Int> else {
                XCTFail("Unexpected error type thrown by ComparableValidator on failure")
                return
            }
            
            switch comparableValidationError {
            case .valueIsAboveMaximumBounds(let max):
                XCTAssertEqual(max, 10)
            default:
                XCTFail("Unexpected ComparableValidationError type thrown by ComparableValidator on failure")
            }
        }
    }

}<commit_msg>Added test for comparble range happy path<commit_after>//
//  ComparableValidatorTests.swift
//  SwiftValidation
//
//  Created by Jon on 02/06/2016.
//  Copyright © 2016 joncotton. All rights reserved.
//

import XCTest
@testable import SwiftValidation

class ComparableValidatorTests: XCTestCase {

    func test_comparable_validator_is_valid_returns_true_for_value_higher_than_minimum_bounds_when_testing_for_minimum_value() {
        let comparableValidator = ComparableValidator.minimumValue(10)
        
        guard let result = try? comparableValidator.isValid(20) else {
            XCTFail("Expected minimum value test to pass when testing higher value than minimum bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
    func test_comparable_validator_is_valid_returns_true_for_value_equal_to_minimum_bounds_when_testing_for_minimum_value() {
        let comparableValidator = ComparableValidator.minimumValue(10)
        
        guard let result = try? comparableValidator.isValid(10) else {
            XCTFail("Expected minimum value test to pass when testing equal value to minimum bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
    func test_comparable_validator_throws_is_below_minimum_bounds_error_for_value_below_minimum_bounds_when_testing_for_minimum_value() {
        let comparableValidator = ComparableValidator.minimumValue(10)
        
        XCTAssertThrowsError(try comparableValidator.isValid(5)) { error in
            guard let comparableValidationError = error as? ComparableValidationError<Int> else {
                XCTFail("Unexpected error type thrown by ComparableValidator on failure")
                return
            }
            
            switch comparableValidationError {
            case .valueIsBelowMinimumBounds(let min):
                XCTAssertEqual(min, 10)
            default:
                XCTFail("Unexpected ComparableValidationError type thrown by ComparableValidator on failure")
            }
        }
    }
    
    func test_comparable_validator_is_valid_returns_true_for_value_lower_than_maximum_bounds_when_testing_for_maximum_value() {
        let comparableValidator = ComparableValidator.maximumValue(10)
        
        guard let result = try? comparableValidator.isValid(5) else {
            XCTFail("Expected maximum value test to pass when testing higher value than maximum bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
    func test_comparable_validator_is_valid_returns_true_for_value_equal_to_maximum_bounds_when_testing_for_maximum_value() {
        let comparableValidator = ComparableValidator.maximumValue(10)
        
        guard let result = try? comparableValidator.isValid(10) else {
            XCTFail("Expected maximum value test to pass when testing equal value to maximum bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
    func test_comparable_validator_throws_is_above_maximum_bounds_error_for_value_above_maximum_bounds_when_testing_for_maximum_value() {
        let comparableValidator = ComparableValidator.maximumValue(10)
        
        XCTAssertThrowsError(try comparableValidator.isValid(20)) { error in
            guard let comparableValidationError = error as? ComparableValidationError<Int> else {
                XCTFail("Unexpected error type thrown by ComparableValidator on failure")
                return
            }
            
            switch comparableValidationError {
            case .valueIsAboveMaximumBounds(let max):
                XCTAssertEqual(max, 10)
            default:
                XCTFail("Unexpected ComparableValidationError type thrown by ComparableValidator on failure")
            }
        }
    }
    
    func test_comparable_validator_is_valid_returns_true_for_value_within_supplied_range_when_testing_for_value_within_range() {
        let comparableValidator = ComparableValidator.range(10, 20)
        
        guard let result = try? comparableValidator.isValid(15) else {
            XCTFail("Expected value in range test to pass when testing value within bounds")
            return
        }
        
        XCTAssertTrue(result)
    }
    
}
{'fraction_non_alphanumeric': 0.049857373186158994, 'fraction_numerical': 0.010169911943445367, 'mean_word_length': 2.662125340599455, 'pattern_counts': {'":': 0, '<': 7, '<?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': '670596', 'n_tokens_mistral': 2131, 'n_tokens_neox': 2015, 'n_words': 450}