<commit_before>//
//  Response.swift
//  Vapor
//
//  Created by <NAME> on 2/3/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import XCTest
@testable import Vapor

class TestResponder: Responder {
    var closure: (Request) throws -> Response

    init(closure: (Request) throws -> Response) {
        self.closure = closure
    }
    func respond(to request: Request) throws -> Response {
        return try closure(request)
    }
}


class RequestTests: XCTestCase {
    static var allTests: [(String, (RequestTests) -> () throws -> Void)] {
        return [
            ("testParse", testParse),
            ("testMultipart", testMultipart),
            ("testMultipartFile", testMultipartFile),
            ("testFormURLEncoded", testFormURLEncoded),
            ("testFormURLEncodedEdge", testFormURLEncodedEdge),
            ("testSplitString", testSplitString)
        ]
    }

    let contentMiddleware = ContentMiddleware()
    let jsonMiddleware = JSONMiddleware()
    let formURLEncodedMiddleware = FormURLEncodedMiddleware()
    let multipartMiddleware = MultipartMiddleware()

    func testParse() {
        let string = "value=123"

        let data = FormURLEncoded.parse(string.data)
        XCTAssert(data["value"]?.int == 123, "Request did not parse correctly")
    }

    func testMultipart() {
        let boundary = "~~vapor~~"

        var body = "--" + boundary + "\r\n"
        body += "Content-Disposition: form-data; name=\"value\"\r\n"
        body += "\r\n"
        body += "123\r\n"<commit_msg>empty middleware<commit_after>//
//  Response.swift
//  Vapor
//
//  Created by <NAME> on 2/3/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import XCTest
@testable import Vapor

class TestResponder: Responder {
    var closure: (Request) throws -> Response

    init(closure: (Request) throws -> Response) {
        self.closure = closure
    }
    func respond(to request: Request) throws -> Response {
        return try closure(request)
    }
}

class RequestTests: XCTestCase {
    static var allTests: [(String, (RequestTests) -> () throws -> Void)] {
        return [
            ("testParse", testParse),
            ("testMultipart", testMultipart),
            ("testMultipartFile", testMultipartFile),
            ("testFormURLEncoded", testFormURLEncoded),
            ("testFormURLEncodedEdge", testFormURLEncodedEdge),
            ("testSplitString", testSplitString)
        ]
    }

    func testParse() {
        let string = "value=123"

        let data = FormURLEncoded.parse(string.data)
        XCTAssert(data["value"]?.int == 123, "Request did not parse correctly")
    }

    func testMultipart() {
        let boundary = "~~vapor~~"

        var body = "--" + boundary + "\r\n"
        body += "Content-Disposition: form-data; name=\"value\"\r\n"
        body += "\r\n"
        body += "123\r\n"
{'fraction_non_alphanumeric': 0.13403141361256546, 'fraction_numerical': 0.0118673647469459, 'mean_word_length': 2.4447115384615383, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '6620664', 'n_tokens_mistral': 887, 'n_tokens_neox': 846, 'n_words': 208}