Explorar o código

Tests files removed from Sources directory.

Damian Kołakowski %!s(int64=10) %!d(string=hai) anos
pai
achega
1028fd946b

+ 0 - 106
Sources/SwifterTestsCommon/SwifterTestsHttpParser.swift

@@ -1,106 +0,0 @@
-//
-//  SwifterTests.swift
-//  SwifterTests
-//
-//  Copyright © 2016 Damian Kołakowski. All rights reserved.
-//
-
-import XCTest
-
-import Swifter
-
-class SwifterTestsHttpParser: XCTestCase {
-    
-    class TestSocket: Socket {
-        var content = [UInt8]()
-        var offset = 0
-        
-        init(_ content: String) {
-            super.init(socketFileDescriptor: -1)
-            self.content.appendContentsOf([UInt8](content.utf8))
-        }
-
-        override func read() throws -> UInt8 {
-            if offset < content.count {
-                let value = self.content[offset]
-                offset = offset + 1
-                return value
-            }
-            throw SocketError.RecvFailed("")
-        }
-    }
-    
-    func testParser() {
-        let parser = HttpParser()
-        
-        do {
-            try parser.readHttpRequest(TestSocket(""))
-            XCTAssertTrue(false, "Parser should throw an error if socket is empty.")
-        } catch { }
-
-        do {
-            try parser.readHttpRequest(TestSocket("12345678"))
-            XCTAssertTrue(false, "Parser should throw an error if status line has single token.")
-        } catch { }
-
-        do {
-            try parser.readHttpRequest(TestSocket("GET HTTP/1.0"))
-            XCTAssertTrue(false, "Parser should throw an error if status line has not enough tokens.")
-        } catch { }
-
-        do {
-            try parser.readHttpRequest(TestSocket("GET / HTTP/1.0"))
-            XCTAssertTrue(false, "Parser should throw an error if there is no next line symbol.")
-        } catch { }
-            
-        do {
-            try parser.readHttpRequest(TestSocket("GET / HTTP/1.0"))
-            XCTAssertTrue(false, "Parser should throw an error if there is no next line symbol.")
-        } catch { }
-        
-        do {
-            try parser.readHttpRequest(TestSocket("GET / HTTP/1.0\r"))
-            XCTAssertTrue(false, "Parser should throw an error if there is no next line symbol.")
-        } catch { }
-        
-        do {
-            try parser.readHttpRequest(TestSocket("GET / HTTP/1.0\n"))
-            XCTAssertTrue(false, "Parser should throw an error if there is no 'Content-Length' header.")
-        } catch { }
-        
-        do {
-            try parser.readHttpRequest(TestSocket("GET / HTTP/1.0\r\nContent-Length: 0\r\n\r\n"))
-        } catch {
-            XCTAssertTrue(false, "Parser should not throw any errors if there is a valid 'Content-Length' header.")
-        }
-        
-        do {
-            try parser.readHttpRequest(TestSocket("GET / HTTP/1.0\nContent-Length: 0\r\n\n"))
-        } catch {
-            XCTAssertTrue(false, "Parser should not throw any errors if there is a valid 'Content-Length' header.")
-        }
-        
-        do {
-            try parser.readHttpRequest(TestSocket("GET / HTTP/1.0\nContent-Length: 5\n\n12345"))
-        } catch {
-            XCTAssertTrue(false, "Parser should not throw any errors if there is a valid 'Content-Length' header.")
-        }
-        
-        do {
-            try parser.readHttpRequest(TestSocket("GET / HTTP/1.0\nContent-Length: 10\r\n\n"))
-            XCTAssertTrue(false, "Parser should throw an error if request' body is too short.")
-        } catch { }
-        
-        var r = try? parser.readHttpRequest(TestSocket("GET / HTTP/1.0\nContent-Length: 10\n\n1234567890"))
-        XCTAssertTrue(r?.method == "GET", "Parser should extract HTTP method name from the status line.")
-        XCTAssertTrue(r?.path == "/", "Parser should extract HTTP path value from the status line.")
-        XCTAssertTrue(r?.headers["content-length"] == "10", "Parser should extract Content-Length header value.")
-        
-        r = try? parser.readHttpRequest(TestSocket("POST / HTTP/1.0\nContent-Length: 10\n\n1234567890"))
-        XCTAssertTrue(r?.method == "POST", "Parser should extract HTTP method name from the status line.")
-        
-        r = try? parser.readHttpRequest(TestSocket("GET / HTTP/1.0\nHeader1: 1\nHeader2: 2\nContent-Length: 0\n\n"))
-        XCTAssertTrue(r?.headers["header1"] == "1", "Parser should extract multiple headers from the request.")
-        XCTAssertTrue(r?.headers["header2"] == "2", "Parser should extract multiple headers from the request.")
-    }
-}

+ 0 - 92
Sources/SwifterTestsCommon/SwifterTestsStringExtensions.swift

@@ -1,92 +0,0 @@
-//
-//  SwifterTests.swift
-//  SwifterTests
-//
-//  Copyright © 2016 Damian Kołakowski. All rights reserved.
-//
-
-import XCTest
-
-import Swifter
-
-class SwifterTestsStringExtensions: XCTestCase {
-    
-    func testSHA1() {
-        XCTAssertEqual("".SHA1(), "da39a3ee5e6b4b0d3255bfef95601890afd80709")
-        XCTAssertEqual("test".SHA1(), "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3")
-        
-        // Values copied from OpenSSL:
-        // https://github.com/openssl/openssl/blob/master/test/sha1test.c
-        
-        XCTAssertEqual("abc".SHA1(), "a9993e364706816aba3e25717850c26c9cd0d89d")
-        XCTAssertEqual("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq".SHA1(),
-            "84983e441c3bd26ebaae4aa1f95129e5e54670f1")
-        
-        XCTAssertEqual(
-            ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +
-             "a9993e364706816aba3e25717850c26c9cd0d89d" +
-             "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +
-             "a9993e364706816aba3e25717850c26c9cd0d89d" +
-             "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +
-             "a9993e364706816aba3e25717850c26c9cd0d89d" +
-             "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +
-             "a9993e364706816aba3e25717850c26c9cd0d89d" +
-             "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +
-             "a9993e364706816aba3e25717850c26c9cd0d89d" +
-             "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +
-             "a9993e364706816aba3e25717850c26c9cd0d89d" +
-             "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq").SHA1(),
-            "a377b0c42d685fdc396e29a9eda7101d900947ca")
-    }
-    
-    func testBASE64() {
-        XCTAssertEqual(String.toBase64([UInt8]("".utf8)), "")
-        
-        // Values copied from OpenSSL:
-        // https://github.com/openssl/openssl/blob/995197ab84901df1cdf83509c4ce3511ea7f5ec0/test/evptests.txt
-        
-        XCTAssertEqual(String.toBase64([UInt8]("h".utf8)), "aA==")
-        XCTAssertEqual(String.toBase64([UInt8]("hello".utf8)), "aGVsbG8=")
-        XCTAssertEqual(String.toBase64([UInt8]("hello world!".utf8)), "aGVsbG8gd29ybGQh")
-        XCTAssertEqual(String.toBase64([UInt8]("OpenSSLOpenSSL\n".utf8)), "T3BlblNTTE9wZW5TU0wK")
-        XCTAssertEqual(String.toBase64([UInt8]("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".utf8)),
-            "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==")
-        XCTAssertEqual(String.toBase64([UInt8]("h".utf8)), "aA==")
-    }
-    
-    func testMiscUnquote() {
-        XCTAssertEqual("".unquote(), "")
-        XCTAssertEqual("\"".unquote(), "\"")
-        XCTAssertEqual("\"\"".unquote(), "")
-        
-        XCTAssertEqual("1234".unquote(), "1234")
-        XCTAssertEqual("1234\"".unquote(), "1234\"")
-        XCTAssertEqual("\"1234".unquote(), "\"1234")
-        XCTAssertEqual("\"1234\"".unquote(), "1234")
-        XCTAssertEqual("\"1234\"".unquote(), "1234")
-        
-        XCTAssertEqual("\"\"\"".unquote(), "\"")
-        XCTAssertEqual("\"\" \"\"".unquote(), "\" \"")
-    }
-    
-    func testMiscTrim() {
-        XCTAssertEqual("".trim(), "")
-        XCTAssertEqual("\n".trim(), "")
-        XCTAssertEqual("\t".trim(), "")
-        XCTAssertEqual("\r".trim(), "")
-        XCTAssertEqual(" ".trim(), "")
-        XCTAssertEqual("      ".trim(), "")
-        XCTAssertEqual("1 test     ".trim(), "1 test")
-        XCTAssertEqual("      test          ".trim(), "test")
-        XCTAssertEqual("   \t\n\rtest          ".trim(), "test")
-        XCTAssertEqual("   \t\n\rtest  n   \n\t asd    ".trim(), "test  n   \n\t asd")
-    }
-
-    func testMiscReplace() {
-        XCTAssertEqual("".replace("+", "-"), "")
-        XCTAssertEqual("test".replace("+", "-"), "test")
-        XCTAssertEqual("+++".replace("+", "-"), "---")
-        XCTAssertEqual("t&e&s&t12%3%".replace("&", "+").replace("%", "+"), "t+e+s+t12+3+")
-        XCTAssertEqual("test 1234 #$%^&*( test   ".replace(" ", "_"), "test_1234_#$%^&*(_test___")
-    }
-}