forked from luximetr/AnyFormatKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for sum input formatter with erasing by 1 symbol.
- Loading branch information
Aleksandr Orlov
committed
Jun 15, 2019
1 parent
ec74c87
commit 2cf0472
Showing
3 changed files
with
100 additions
and
182 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
178 changes: 0 additions & 178 deletions
178
Tests/SumTextInputFormatterTests/Simple/Delete/SumTextInputFormatterDeleteTests.swift
This file was deleted.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
...SumTextInputFormatterTests/Simple/Delete/SumTextInputFormatterErasingBy1SymbolTests.swift
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,96 @@ | ||
// | ||
// SumTextInputFormatterErasingBy1SymbolTests.swift | ||
// AnyFormatKitTests | ||
// | ||
// Created by branderstudio on 15.06.2019. | ||
// Copyright © 2019 BRANDERSTUDIO. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import AnyFormatKit | ||
|
||
class SumTextInputFormatterErasingBy1SymbolTests: XCTestCase { | ||
|
||
let formatter = SumTextInputFormatter(textPattern: "#,###.##") | ||
|
||
// 12,345.6|7| -> 12,345.6| | ||
func test1() { | ||
let actualResult = formatter.formatInput( | ||
currentText: "12,345.67", | ||
range: NSRange(location: 8, length: 1), | ||
replacementString: "") | ||
let expectedResult = FormattedTextValue(formattedText: "12,345.6", caretBeginOffset: 8) | ||
XCTAssert(actualResult == expectedResult, "\(expectedResult) must be equal to \(actualResult)") | ||
} | ||
|
||
// 12,345.|6| -> 12,345.| | ||
func test2() { | ||
let actualResult = formatter.formatInput( | ||
currentText: "12,345.6", | ||
range: NSRange(location: 7, length: 1), | ||
replacementString: "") | ||
let expectedResult = FormattedTextValue(formattedText: "12,345.", caretBeginOffset: 7) | ||
XCTAssert(actualResult == expectedResult, "\(expectedResult) must be equal to \(actualResult)") | ||
} | ||
|
||
// 12,345|.| -> 12,345| | ||
func test3() { | ||
let actualResult = formatter.formatInput( | ||
currentText: "12,345.", | ||
range: NSRange(location: 6, length: 1), | ||
replacementString: "") | ||
let expectedResult = FormattedTextValue(formattedText: "12,345", caretBeginOffset: 6) | ||
XCTAssert(actualResult == expectedResult, "\(expectedResult) must be equal to \(actualResult)") | ||
} | ||
|
||
// 12,34|5| -> 1,234| | ||
func test4() { | ||
let actualResult = formatter.formatInput( | ||
currentText: "12,345", | ||
range: NSRange(location: 5, length: 1), | ||
replacementString: "") | ||
let expectedResult = FormattedTextValue(formattedText: "1,234", caretBeginOffset: 5) | ||
XCTAssert(actualResult == expectedResult, "\(expectedResult) must be equal to \(actualResult)") | ||
} | ||
|
||
// 1,23|4| -> 123| | ||
func test5() { | ||
let actualResult = formatter.formatInput( | ||
currentText: "1,234", | ||
range: NSRange(location: 4, length: 1), | ||
replacementString: "") | ||
let expectedResult = FormattedTextValue(formattedText: "123", caretBeginOffset: 3) | ||
XCTAssert(actualResult == expectedResult, "\(expectedResult) must be equal to \(actualResult)") | ||
} | ||
|
||
// 12|3| -> 12| | ||
func test6() { | ||
let actualResult = formatter.formatInput( | ||
currentText: "123", | ||
range: NSRange(location: 2, length: 1), | ||
replacementString: "") | ||
let expectedResult = FormattedTextValue(formattedText: "12", caretBeginOffset: 2) | ||
XCTAssert(actualResult == expectedResult, "\(expectedResult) must be equal to \(actualResult)") | ||
} | ||
|
||
// 1|2| -> 1| | ||
func test7() { | ||
let actualResult = formatter.formatInput( | ||
currentText: "12", | ||
range: NSRange(location: 1, length: 1), | ||
replacementString: "") | ||
let expectedResult = FormattedTextValue(formattedText: "1", caretBeginOffset: 1) | ||
XCTAssert(actualResult == expectedResult, "\(expectedResult) must be equal to \(actualResult)") | ||
} | ||
|
||
// |1| -> "|" | ||
func test8() { | ||
let actualResult = formatter.formatInput( | ||
currentText: "1", | ||
range: NSRange(location: 0, length: 1), | ||
replacementString: "") | ||
let expectedResult = FormattedTextValue(formattedText: "", caretBeginOffset: 0) | ||
XCTAssert(actualResult == expectedResult, "\(expectedResult) must be equal to \(actualResult)") | ||
} | ||
|
||
} |