<commit_before>//
//  Created by <NAME> on 24/11/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import XCTest
import SwiftyUtils

final class StringExtensionTests: XCTestCase {

    override func setUp() {
        super.setUp()
    }

    override func tearDown() {
        super.tearDown()
    }

}

// MARK - Subscript

extension StringExtensionTests {

    func testSubscriptIndex() {
        let aString = "Hello world"
        XCTAssertEqual(aString[0], "H")
        XCTAssertEqual(aString[2], "l")
    }

    func testSubscriptRange() {
        let aString = "Hello world"
        XCTAssertEqual(aString[Range(1...3)], "ell")
    }

}

// MARK: - Misc

extension StringExtensionTests {

    func testLength() {
        let aString = "Hello world"
        XCTAssertEqual(aString.length, aString.characters.count)
    }

    func testContains() {
        let string = "Hello world"
        XCTAssertTrue(string.contains("lo wo"))
        XCTAssertFalse(string.contains("wo lo"))
    }

}

// MARK: - Validator

extension StringExtensionTests {

    func testIsNumeric() {
        XCTAssertTrue("425252".isNumeric)
        XCTAssertFalse("test".isNumeric)
    }

    func testIsEmailValid() {
        var aString = "<EMAIL>"
        XCTAssertTrue(aString.isEmail)
        aString = "test"
        XCTAssertFalse(aString.isEmail)
        aString = "test@gmail"
        XCTAssertFalse(aString.isEmail)
        aString = "<EMAIL>"
        XCTAssertFalse(aString.isEmail)
    }

}

// MARK: - Computed Properties

extension StringExtensionTests {

    func testUncamelized() {
        var camelString = "isCamelled"
        XCTAssertEqual(camelString.uncamelized, "is_camelled")
        camelString = "is_camelled"
        XCTAssertEqual(camelString.uncamelized, "is_camelled")
        camelString = "isCamelled_invalidsYntax"
        XCTAssertEqual(camelString.uncamelized, "is_camelled_invalids_yntax")
    }

    func testCapitalizedFirst() {
        var aString = "hello world"
        aString = aString.capitalizedFirst
        XCTAssertEqual(aString[0], "H")
    }

}

// MARK: - Transform

extension StringExtensionTests {

    func testTrim() {
        var string = "space space"
        string.trim()
        XCTAssertFalse(string.contains(" "))
    }

    func testTruncate() {
        var string = "0123456789aaaa"
        string.truncate(limit: 10)
        XCTAssertEqual(string, "0123456789...")<commit_msg>Improving `capitalizeFirst` tests<commit_after>//
//  Created by <NAME> on 24/11/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import XCTest
import SwiftyUtils

final class StringExtensionTests: XCTestCase {

    override func setUp() {
        super.setUp()
    }

    override func tearDown() {
        super.tearDown()
    }

}

// MARK - Subscript

extension StringExtensionTests {

    func testSubscriptIndex() {
        let aString = "Hello world"
        XCTAssertEqual(aString[0], "H")
        XCTAssertEqual(aString[2], "l")
    }

    func testSubscriptRange() {
        let aString = "Hello world"
        XCTAssertEqual(aString[Range(1...3)], "ell")
    }

}

// MARK: - Misc

extension StringExtensionTests {

    func testLength() {
        let aString = "Hello world"
        XCTAssertEqual(aString.length, aString.characters.count)
    }

    func testContains() {
        let string = "Hello world"
        XCTAssertTrue(string.contains("lo wo"))
        XCTAssertFalse(string.contains("wo lo"))
    }

}

// MARK: - Validator

extension StringExtensionTests {

    func testIsNumeric() {
        XCTAssertTrue("425252".isNumeric)
        XCTAssertFalse("test".isNumeric)
    }

    func testIsEmailValid() {
        var aString = "<EMAIL>"
        XCTAssertTrue(aString.isEmail)
        aString = "test"
        XCTAssertFalse(aString.isEmail)
        aString = "test@gmail"
        XCTAssertFalse(aString.isEmail)
        aString = "<EMAIL>"
        XCTAssertFalse(aString.isEmail)
    }

}

// MARK: - Computed Properties

extension StringExtensionTests {

    func testUncamelized() {
        var camelString = "isCamelled"
        XCTAssertEqual(camelString.uncamelized, "is_camelled")
        camelString = "is_camelled"
        XCTAssertEqual(camelString.uncamelized, "is_camelled")
        camelString = "isCamelled_invalidsYntax"
        XCTAssertEqual(camelString.uncamelized, "is_camelled_invalids_yntax")
    }

    func testCapitalizedFirst() {
        var aString = "hello world"
        aString = aString.capitalizedFirst
        XCTAssertEqual(aString, "Hello world")
    }

}

// MARK: - Transform

extension StringExtensionTests {

    func testTrim() {
        var string = "space space"
        string.trim()
        XCTAssertFalse(string.contains(" "))
    }

    func testTruncate() {
        var string = "0123456789aaaa"
        string.truncate(limit: 10)
        XCTAssertEqual(string, "0123456789...")
{'fraction_non_alphanumeric': 0.11008798854102722, 'fraction_numerical': 0.017393083691426232, 'mean_word_length': 2.573099415204678, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2399453', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1539, 'n_words': 296}