<commit_before>//
//  NodeBoundsTests.swift
//  Macaw
//
//  Created by <NAME> on 5/10/17.
//  Copyright © 2017 Exyte. All rights reserved.
//

#if os(iOS)

import XCTest
@testable import Macaw

class NodeBoundsTests: XCTestCase {
    var window: UIWindow!
    
    override func setUp() {
        super.setUp()
        
        window = UIWindow()
    }
    
    override func tearDown() {
        super.tearDown()
    }
    
    func checkBounds(rect1: Rect?, rect2: Rect) {
        if let rect = rect1 {
            XCTAssertTrue(rect == rect2, "Test failed. Rects not equal")
        }
    }
    
    func validate(node: Node, referenceBounds: Rect) {
        let passingThreshold = 0.2
        
        var testResult = false
        if let bounds = node.bounds {
            //print("\n<rect x=\"\(Double(round(100*bounds.x)/100))\" y=\"\(Double(round(100*bounds.y)/100))\" width=\"\(Double(round(100*bounds.w)/100))\" height=\"\(Double(round(100*bounds.h)/100))\" stroke=\"red\" stroke-width=\"1\" fill=\"none\"/>\n")
            testResult = (Double(round(100*bounds.x)/100) - referenceBounds.x < passingThreshold)
            testResult = testResult && (Double(round(100*bounds.y)/100) - referenceBounds.y < passingThreshold)
            testResult = testResult && (Double(round(100*bounds.w)/100) - referenceBounds.w < passingThreshold)
            testResult = testResult && (Double(round(100*bounds.h)/100) - referenceBounds.h < passingThreshold)
        }
        
        XCTAssert(testResult)
    }
    
    // MARK: - Shapes
    
    func testSimpleShapeZeroBounds() {
        let shape = Shape(form: Rect.zero())
    
        checkBounds(rect1: shape.bounds, rect2: Rect.zero())
    }
    
    func testSimpleShapeRect() {
        // Rect / RoundRect
        let shape = Shape(form: RoundRect(rect: Rect(x: 20.0, y: 15.0, w: 10.0, h: 10.0), rx: 8.0, ry: 1.0))
        let targetRect = Rect(x: 20.0, y: 15.0, w: 10.0, h: 10.0)
        
        checkBounds(rect1: shape.bounds, rect2: targetRect)
    }
    
    func testShapePoint() {
        let shape = Shape(form: Point(x: 10.0, y: 20.0))
        let targetRect = Rect(x: 10.0, y: 20.0, w: 0.0, h: 0.0)
        <commit_msg>Removing unused commented code<commit_after>//
//  NodeBoundsTests.swift
//  Macaw
//
//  Created by <NAME> on 5/10/17.
//  Copyright © 2017 Exyte. All rights reserved.
//

#if os(iOS)

import XCTest
@testable import Macaw

class NodeBoundsTests: XCTestCase {
    var window: UIWindow!
    
    override func setUp() {
        super.setUp()
        
        window = UIWindow()
    }
    
    override func tearDown() {
        super.tearDown()
    }
    
    func checkBounds(rect1: Rect?, rect2: Rect) {
        if let rect = rect1 {
            XCTAssertTrue(rect == rect2, "Test failed. Rects not equal")
        }
    }
    
    func validate(node: Node, referenceBounds: Rect) {
        let passingThreshold = 0.2
        
        var testResult = false
        if let bounds = node.bounds {
            testResult = (Double(round(100*bounds.x)/100) - referenceBounds.x < passingThreshold)
            testResult = testResult && (Double(round(100*bounds.y)/100) - referenceBounds.y < passingThreshold)
            testResult = testResult && (Double(round(100*bounds.w)/100) - referenceBounds.w < passingThreshold)
            testResult = testResult && (Double(round(100*bounds.h)/100) - referenceBounds.h < passingThreshold)
        }
        
        XCTAssert(testResult)
    }
    
    // MARK: - Shapes
    
    func testSimpleShapeZeroBounds() {
        let shape = Shape(form: Rect.zero())
    
        checkBounds(rect1: shape.bounds, rect2: Rect.zero())
    }
    
    func testSimpleShapeRect() {
        // Rect / RoundRect
        let shape = Shape(form: RoundRect(rect: Rect(x: 20.0, y: 15.0, w: 10.0, h: 10.0), rx: 8.0, ry: 1.0))
        let targetRect = Rect(x: 20.0, y: 15.0, w: 10.0, h: 10.0)
        
        checkBounds(rect1: shape.bounds, rect2: targetRect)
    }
    
    func testShapePoint() {
        let shape = Shape(form: Point(x: 10.0, y: 20.0))
        let targetRect = Rect(x: 10.0, y: 20.0, w: 0.0, h: 0.0)
        
{'fraction_non_alphanumeric': 0.1411338962605549, 'fraction_numerical': 0.048009650180940895, 'mean_word_length': 2.1266968325791855, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 6, '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': '116439', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1356, 'n_words': 319}