From 5f0d996c91ab1a14579e6c54534467323f0de4a4 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Fri, 20 May 2022 18:32:49 +0800 Subject: [PATCH] test: Long text character counting. --- Tests/ReadabilityTests/CommonMetrics.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Tests/ReadabilityTests/CommonMetrics.swift b/Tests/ReadabilityTests/CommonMetrics.swift index 8b5247b..5776325 100644 --- a/Tests/ReadabilityTests/CommonMetrics.swift +++ b/Tests/ReadabilityTests/CommonMetrics.swift @@ -31,4 +31,21 @@ final class CommonMetrics: XCTestCase { .avgWordsPerSentence: 2.0 ]) } + + func testLongTextCharCount() throws { + let calc = RACommonMetricsCalculator(metrics: [ + .characterCount, + ]) + + let text = + """ + The best things in an artist’s work are so much a matter of intuition, that there is much to be said for the point of view that would altogether discourage intellectual inquiry into artistic phenomena on the part of the artist. Intuitions are shy things and apt to disappear if looked into too closely. And there is undoubtedly a danger that too much knowledge and training may supplant the natural intuitive feeling of a student, leaving only a cold knowledge of the means of expression in its place. For the artist, if he has the right stuff in him + """ + + let results = calc.calculate(on: text) + + XCTAssertEqual(results, [ + .characterCount: 446.0, + ]) + } }