-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the issue of tracking when the value is equal to the max value an…
…d add tests for this part
- Loading branch information
1 parent
93fb96c
commit a19a4fc
Showing
2 changed files
with
75 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// CircularSliderHelperTests.swift | ||
// HGCircularSlider_Tests | ||
// | ||
// Created by Hamza GHAZOUANI on 24/07/2019. | ||
// Copyright © 2019 CocoaPods. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import HGCircularSlider | ||
|
||
extension CGFloat { | ||
|
||
var toDegrees: CGFloat { | ||
return self * 180.0 / CGFloat(Double.pi) | ||
} | ||
} | ||
|
||
class CircularSliderHelperTests: XCTestCase { | ||
|
||
let cirlceInterval = Interval(min: 0 , max: CGFloat(2 * Double.pi)) | ||
let valuesInterval = Interval(min: 0, max: 1.2) | ||
|
||
func testInitialValueScale() { | ||
// Given | ||
let value = valuesInterval.min | ||
|
||
// Thene | ||
let angle = CircularSliderHelper.scaleValue(value, fromInterval: valuesInterval, toInterval: cirlceInterval).toDegrees | ||
XCTAssertEqual(angle, 0) | ||
} | ||
|
||
func testFinalValueScale() { | ||
// Given | ||
let value: CGFloat = valuesInterval.max | ||
|
||
// Thene | ||
let angle = CircularSliderHelper.scaleValue(value, fromInterval: valuesInterval, toInterval: cirlceInterval).toDegrees | ||
XCTAssertEqual(angle, 360) | ||
} | ||
|
||
func testMedianValueScale() { | ||
// Given | ||
let value: CGFloat = valuesInterval.max / 2 | ||
|
||
// Thene | ||
let angle = CircularSliderHelper.scaleValue(value, fromInterval: valuesInterval, toInterval: cirlceInterval).toDegrees | ||
XCTAssertEqual(angle, 180) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters