Skip to content

Commit

Permalink
Update Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
willdale committed Apr 15, 2021
1 parent a1cb5be commit d37f4a6
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 117 deletions.
1 change: 1 addition & 0 deletions Tests/SwiftUIChartsTests/BarCharts/BarChartTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import SwiftUI
@testable import SwiftUICharts

final class BarChartTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import SwiftUI
@testable import SwiftUICharts

final class GroupedBarChartTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import SwiftUI
@testable import SwiftUICharts

final class StackedBarChartTests: XCTestCase {
Expand Down
234 changes: 117 additions & 117 deletions Tests/SwiftUIChartsTests/LineCharts/LineChartPathTests.swift
Original file line number Diff line number Diff line change
@@ -1,117 +1,117 @@
//import XCTest

//@testable import SwiftUICharts

//final class LineChartPathTests: XCTestCase {
//
// let chartData = LineChartData(dataSets: LineDataSet(dataPoints: [
// LineChartDataPoint(value: 0),
// LineChartDataPoint(value: 25),
// LineChartDataPoint(value: 50),
// LineChartDataPoint(value: 75),
// LineChartDataPoint(value: 100)
// ]))
//
// let rect : CGRect = CGRect(x: 0, y: 0, width: 100, height: 100)
// let touchLocation: CGPoint = CGPoint(x: 25, y: 25)
//
// func testGetIndicatorLocation() {
//
// let test = LineChartData.getIndicatorLocation(rect : rect,
// dataPoints : chartData.dataSets.dataPoints,
// touchLocation : touchLocation,
// lineType : .line,
// minValue : chartData.minValue,
// range : chartData.range,
// ignoreZero : false)
//
// XCTAssertEqual(test.x, 25, accuracy: 0.1)
// XCTAssertEqual(test.y, 75, accuracy: 0.1)
// }
//
//
// func testGetPercentageOfPath() {
//
// let path = Path.straightLine(rect : rect,
// dataPoints : chartData.dataSets.dataPoints,
// minValue : chartData.minValue,
// range : chartData.range,
// isFilled : false)
//
// let test = LineChartData.getPercentageOfPath(path: path, touchLocation: touchLocation)
//
// XCTAssertEqual(test, 0.25, accuracy: 0.1)
// }
//
// func testGetTotalLength() {
//
// let path = Path.straightLine(rect : rect,
// dataPoints : chartData.dataSets.dataPoints,
// minValue : chartData.minValue,
// range : chartData.range,
// isFilled : false)
//
// let test = LineChartData.getTotalLength(of: path)
//
// XCTAssertEqual(test, 141.42, accuracy: 0.01)
// }
//
// func testGetLengthToTouch() {
//
// let path = Path.straightLine(rect : rect,
// dataPoints : chartData.dataSets.dataPoints,
// minValue : chartData.minValue,
// range : chartData.range,
// isFilled : false)
//
// let test = LineChartData.getLength(to: touchLocation, on: path)
//
// XCTAssertEqual(test, 35.35, accuracy: 0.01)
// }
//
// func testRelativePoint() {
//
// let pointOne = CGPoint(x: 0.0, y: 0.0)
// let pointTwo = CGPoint(x: 100, y: 100)
//
// let test = LineChartData.relativePoint(from: pointOne, to: pointTwo, touchX: touchLocation.x)
//
// XCTAssertEqual(test.x, 25, accuracy: 0.01)
// XCTAssertEqual(test.y, 25, accuracy: 0.01)
// }
//
// func testDistanceToTouch() {
//
// let pointOne = CGPoint(x: 0.0, y: 0.0)
// let pointTwo = CGPoint(x: 100, y: 100)
//
// let test = LineChartData.distanceToTouch(from: pointOne, to: pointTwo, touchX: touchLocation.x)
//
// XCTAssertEqual(test, 35.355, accuracy: 0.01)
// }
//
// func testDistance() {
//
// let pointOne = CGPoint(x: 0.0, y: 0.0)
// let pointTwo = CGPoint(x: 100, y: 100)
//
// let test = LineChartData.distance(from: pointOne, to: pointTwo)
//
// XCTAssertEqual(test, 141.421356237309, accuracy: 0.01)
// }
//
// func testGetLocationOnPath() {
//
// let path = Path.straightLine(rect : rect,
// dataPoints : chartData.dataSets.dataPoints,
// minValue : chartData.minValue,
// range : chartData.range,
// isFilled : false)
//
//
// let test = LineChartData.locationOnPath(0.5, path)
//
// XCTAssertEqual(test.x, 50, accuracy: 0.1)
// XCTAssertEqual(test.y, 50, accuracy: 0.1)
// }
//}
import XCTest
import SwiftUI
@testable import SwiftUICharts

final class LineChartPathTests: XCTestCase {

let chartData = LineChartData(dataSets: LineDataSet(dataPoints: [
LineChartDataPoint(value: 0),
LineChartDataPoint(value: 25),
LineChartDataPoint(value: 50),
LineChartDataPoint(value: 75),
LineChartDataPoint(value: 100)
]))

let rect : CGRect = CGRect(x: 0, y: 0, width: 100, height: 100)
let touchLocation: CGPoint = CGPoint(x: 25, y: 25)

func testGetIndicatorLocation() {

let test = LineChartData.getIndicatorLocation(rect : rect,
dataPoints : chartData.dataSets.dataPoints,
touchLocation : touchLocation,
lineType : .line,
minValue : chartData.minValue,
range : chartData.range,
ignoreZero : false)

XCTAssertEqual(test.x, 25, accuracy: 0.1)
XCTAssertEqual(test.y, 75, accuracy: 0.1)
}


func testGetPercentageOfPath() {

let path = Path.straightLine(rect : rect,
dataPoints : chartData.dataSets.dataPoints,
minValue : chartData.minValue,
range : chartData.range,
isFilled : false)

let test = LineChartData.getPercentageOfPath(path: path, touchLocation: touchLocation)

XCTAssertEqual(test, 0.25, accuracy: 0.1)
}

func testGetTotalLength() {

let path = Path.straightLine(rect : rect,
dataPoints : chartData.dataSets.dataPoints,
minValue : chartData.minValue,
range : chartData.range,
isFilled : false)

let test = LineChartData.getTotalLength(of: path)

XCTAssertEqual(test, 141.42, accuracy: 0.01)
}

func testGetLengthToTouch() {

let path = Path.straightLine(rect : rect,
dataPoints : chartData.dataSets.dataPoints,
minValue : chartData.minValue,
range : chartData.range,
isFilled : false)

let test = LineChartData.getLength(to: touchLocation, on: path)

XCTAssertEqual(test, 35.35, accuracy: 0.01)
}

func testRelativePoint() {

let pointOne = CGPoint(x: 0.0, y: 0.0)
let pointTwo = CGPoint(x: 100, y: 100)

let test = LineChartData.relativePoint(from: pointOne, to: pointTwo, touchX: touchLocation.x)

XCTAssertEqual(test.x, 25, accuracy: 0.01)
XCTAssertEqual(test.y, 25, accuracy: 0.01)
}

func testDistanceToTouch() {

let pointOne = CGPoint(x: 0.0, y: 0.0)
let pointTwo = CGPoint(x: 100, y: 100)

let test = LineChartData.distanceToTouch(from: pointOne, to: pointTwo, touchX: touchLocation.x)

XCTAssertEqual(test, 35.355, accuracy: 0.01)
}

func testDistance() {

let pointOne = CGPoint(x: 0.0, y: 0.0)
let pointTwo = CGPoint(x: 100, y: 100)

let test = LineChartData.distance(from: pointOne, to: pointTwo)

XCTAssertEqual(test, 141.421356237309, accuracy: 0.01)
}

func testGetLocationOnPath() {

let path = Path.straightLine(rect : rect,
dataPoints : chartData.dataSets.dataPoints,
minValue : chartData.minValue,
range : chartData.range,
isFilled : false)


let test = LineChartData.locationOnPath(0.5, path)

XCTAssertEqual(test.x, 50, accuracy: 0.1)
XCTAssertEqual(test.y, 50, accuracy: 0.1)
}
}
1 change: 1 addition & 0 deletions Tests/SwiftUIChartsTests/LineCharts/LineChartTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import SwiftUI
@testable import SwiftUICharts

final class LineChartTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import XCTest
import SwiftUI
@testable import SwiftUICharts

final class MultiLineChartTest: XCTestCase {
Expand Down

0 comments on commit d37f4a6

Please sign in to comment.