<commit_before>/*
 *   WKTReaderTests
 *
 *   Copyright 2016 <NAME>
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 *   Created by <NAME> on 2/10/16.
 */

import XCTest
import GeoFeatures

#if (os(OSX) || os(iOS) || os(tvOS) || os(watchOS)) && SWIFT_PACKAGE
    /// TODO: Remove this after figuring out why there seems to be a symbol conflict (error: cannot specialize a non-generic definition) with another Polygon on Swift PM on Apple platforms only.
    import struct GeoFeatures.Polygon
#endif

// MARK: - Coordinate2D, FloatingPrecision, Cartesian -

class WKTReader_Coordinate2D_FloatingPrecision_Cartesian_Tests: XCTestCase {

    private typealias WKTReaderType = WKTReader<Coordinate2D>
    private var wktReader = WKTReaderType(precision: FloatingPrecision(), coordinateReferenceSystem: Cartesian())

    // MARK: - Init

    func testRead_Point_Float_Valid() {

        let input = "POINT (1.0 1.0)"
        let expected = Point<Coordinate2D>(coordinate: (x: 1.0, y: 1.0))

        XCTAssertEqual(try wktReader.read(wkt: input) as? Point<Coordinate2D>, expected)
    }

    // MARK: - General

    func testRead_Invalid_Geometry() {

        let input = "INVALID (1.0 1.0)"
        let expected = "INVALID (1.0 1.0)"  /// TODO: Invalid message, please update the class to throw a more descriptive message.

        XCTAssertThrowsError(try wktReader.read(wkt: input)) { error in
            if case ParseError.unsupportedType(let message) = error {
                XCTAssertEqual(message, expected)
            } else {
                XCTFail("Wrong error thrown")
            }
        }
    }

    // MARK: - Point
<commit_msg>Update WKTReaderTests.swift to reflect changes in unsupportedType error message.<commit_after>/*
 *   WKTReaderTests
 *
 *   Copyright 2016 <NAME>
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 *   Created by <NAME> on 2/10/16.
 */

import XCTest
import GeoFeatures

#if (os(OSX) || os(iOS) || os(tvOS) || os(watchOS)) && SWIFT_PACKAGE
    /// TODO: Remove this after figuring out why there seems to be a symbol conflict (error: cannot specialize a non-generic definition) with another Polygon on Swift PM on Apple platforms only.
    import struct GeoFeatures.Polygon
#endif

// MARK: - Coordinate2D, FloatingPrecision, Cartesian -

class WKTReader_Coordinate2D_FloatingPrecision_Cartesian_Tests: XCTestCase {

    private typealias WKTReaderType = WKTReader<Coordinate2D>
    private var wktReader = WKTReaderType(precision: FloatingPrecision(), coordinateReferenceSystem: Cartesian())

    // MARK: - Init

    func testRead_Point_Float_Valid() {

        let input = "POINT (1.0 1.0)"
        let expected = Point<Coordinate2D>(coordinate: (x: 1.0, y: 1.0))

        XCTAssertEqual(try wktReader.read(wkt: input) as? Point<Coordinate2D>, expected)
    }

    // MARK: - General

    func testRead_Invalid_Geometry() {

        let input = "DUMMYTYPE (1.0 1.0)"
        let expected = "Unsupported type -> 'DUMMYTYPE (1.0 1.0)'"

        XCTAssertThrowsError(try wktReader.read(wkt: input)) { error in
            if case ParseError.unsupportedType(let message) = error {
                XCTAssertEqual(message, expected)
            } else {
                XCTFail("Wrong error thrown")
            }
        }
    }

    // MARK: - Point

{'fraction_non_alphanumeric': 0.09212344541685859, 'fraction_numerical': 0.01566098572086596, 'mean_word_length': 3.006457564575646, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6949420', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1275, 'n_words': 433}