-
-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Link folder structure on storage to project souce files
- Loading branch information
Showing
315 changed files
with
1,786 additions
and
2,052 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,36 @@ | ||
// | ||
// ArithmeticsTests.swift | ||
// | ||
// CotEditor | ||
// https://coteditor.com | ||
// | ||
// Created by 1024jp on 2022-06-30. | ||
// | ||
// --------------------------------------------------------------------------- | ||
// | ||
// © 2022-2024 1024jp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Testing | ||
@testable import CotEditor | ||
|
||
struct ArithmeticsTests { | ||
|
||
@Test func digits() { | ||
|
||
#expect(0.digits == [0]) | ||
#expect(1024.digits == [4, 2, 0, 1]) | ||
} | ||
} |
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,84 @@ | ||
// | ||
// CollectionTests.swift | ||
// Tests | ||
// | ||
// CotEditor | ||
// https://coteditor.com | ||
// | ||
// Created by 1024jp on 2017-03-29. | ||
// | ||
// --------------------------------------------------------------------------- | ||
// | ||
// © 2017-2024 1024jp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Testing | ||
@testable import CotEditor | ||
|
||
struct CollectionTests { | ||
|
||
@Test func appendUnique() { | ||
|
||
var array = [0, 1, 2, 3, 4] | ||
|
||
array.appendUnique(0, maximum: 5) | ||
#expect(array == [1, 2, 3, 4, 0]) | ||
|
||
array.appendUnique(6, maximum: 5) | ||
#expect(array == [2, 3, 4, 0, 6]) | ||
|
||
array.appendUnique(7, maximum: 6) | ||
#expect(array == [2, 3, 4, 0, 6, 7]) | ||
|
||
array.appendUnique(6, maximum: 3) | ||
#expect(array == [0, 7, 6]) | ||
} | ||
|
||
|
||
@Test func mapKeys() { | ||
|
||
let dict = [1: 1, 2: 2, 3: 3] | ||
let mapped = dict.mapKeys { String($0 * 10) } | ||
|
||
#expect(mapped == ["10": 1, "20": 2, "30": 3]) | ||
} | ||
|
||
|
||
@Test func rawRepresentable() { | ||
|
||
enum TestKey: String { | ||
case dog, cat, cow | ||
} | ||
var dict = ["dog": "🐶", "cat": "🐱"] | ||
|
||
#expect(dict[TestKey.dog] == dict[TestKey.dog.rawValue]) | ||
#expect(dict[TestKey.cow] == nil) | ||
|
||
dict[TestKey.cow] = "🐮" | ||
#expect(dict[TestKey.cow] == "🐮") | ||
} | ||
|
||
|
||
@Test(arguments: 0..<10) func sort(_: Int) { | ||
|
||
var array: [Int] = (0..<10).map { _ in .random(in: 0..<100) } | ||
let sorted = array.sorted { $0 < $1 } | ||
|
||
#expect(array.sorted() == sorted) | ||
|
||
array.sort() | ||
#expect(array == sorted) | ||
} | ||
} |
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,70 @@ | ||
// | ||
// ComparableTests.swift | ||
// | ||
// CotEditor | ||
// https://coteditor.com | ||
// | ||
// Created by 1024jp on 2024-05-25. | ||
// | ||
// --------------------------------------------------------------------------- | ||
// | ||
// © 2024 1024jp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import Testing | ||
@testable import CotEditor | ||
|
||
struct ComparableTests { | ||
|
||
@Test func clamp() { | ||
|
||
#expect((-2).clamped(to: -10...10) == -2) | ||
#expect(5.clamped(to: 6...10) == 6) | ||
#expect(20.clamped(to: 6...10) == 10) | ||
} | ||
|
||
|
||
@Test func compareBool() { | ||
|
||
#expect([false, true, false, true, false].sorted() == [true, true, false, false, false]) | ||
} | ||
|
||
|
||
@Test func compareBoolItem() { | ||
|
||
struct Item: Equatable { | ||
|
||
var id: Int | ||
var bool: Bool | ||
} | ||
|
||
let items = [ | ||
Item(id: 0, bool: false), | ||
Item(id: 1, bool: true), | ||
Item(id: 2, bool: true), | ||
Item(id: 3, bool: false), | ||
Item(id: 4, bool: true), | ||
] | ||
|
||
#expect(items.sorted(using: [KeyPathComparator(\.bool)]) == [ | ||
Item(id: 1, bool: true), | ||
Item(id: 2, bool: true), | ||
Item(id: 4, bool: true), | ||
Item(id: 0, bool: false), | ||
Item(id: 3, bool: false), | ||
]) | ||
} | ||
} |
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,84 @@ | ||
// | ||
// EncodingTests.swift | ||
// Tests | ||
// | ||
// CotEditor | ||
// https://coteditor.com | ||
// | ||
// Created by 1024jp on 2016-01-16. | ||
// | ||
// --------------------------------------------------------------------------- | ||
// | ||
// © 2016-2024 1024jp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import Testing | ||
@testable import CotEditor | ||
|
||
struct EncodingTests { | ||
|
||
@Test func encodeYen() throws { | ||
|
||
// encodings listed in faq_about_yen_backslash.html | ||
let ascii = try #require(CFStringEncodings(rawValue: CFIndex(CFStringBuiltInEncodings.ASCII.rawValue))) | ||
let inHelpCFEncodings: [CFStringEncodings] = [ | ||
.dosJapanese, | ||
.EUC_JP, // Japanese (EUC) | ||
.EUC_TW, // Traditional Chinese (EUC) | ||
.EUC_CN, // Simplified Chinese (GB 2312) | ||
.EUC_KR, // Korean (EUC) | ||
.dosKorean, // Korean (Windows, DOS) | ||
.dosThai, // Thai (Windows, DOS) | ||
.isoLatinThai, // Thai (ISO 8859-11) | ||
|
||
.macArabic, // Arabic (Mac OS) | ||
.isoLatinArabic, // Arabic (ISO 8859-6) | ||
.macHebrew, // Hebrew (Mac OS) | ||
.isoLatinGreek, // Greek (ISO 8859-7) | ||
.macCyrillic, // Cyrillic (Mac OS) | ||
.isoLatinCyrillic, // Cyrillic (ISO 8859-5) | ||
.windowsCyrillic, // Cyrillic (Windows) | ||
.macCentralEurRoman, // Central European (Mac OS) | ||
.isoLatin2, // Central European (ISO Latin 2) | ||
.isoLatin3, // Western (ISO Latin 3) | ||
.isoLatin4, // Central European (ISO Latin 4) | ||
.dosLatinUS, // Latin-US (DOS) | ||
.windowsLatin2, // Central European (Windows Latin 2) | ||
.isoLatin6, // Nordic (ISO Latin 6) | ||
.isoLatin7, // Baltic (ISO Latin 7) | ||
.isoLatin8, // Celtic (ISO Latin 8) | ||
.isoLatin10, // Romanian (ISO Latin 10) | ||
.dosRussian, // Russian (DOS) | ||
ascii, // Western (ASCII) | ||
] | ||
let inHelpEncodings = inHelpCFEncodings | ||
.map(\.rawValue) | ||
.map(CFStringEncoding.init) | ||
.map(String.Encoding.init(cfEncoding:)) | ||
let availableEncodings = DefaultSettings.encodings | ||
.filter { $0 != kCFStringEncodingInvalidId } | ||
.map(String.Encoding.init(cfEncoding:)) | ||
let yenIncompatibleEncodings = availableEncodings | ||
.filter { !"¥".canBeConverted(to: $0) } | ||
|
||
for encoding in yenIncompatibleEncodings { | ||
#expect(inHelpEncodings.contains(encoding), "\(String.localizedName(of: encoding))") | ||
} | ||
for encoding in inHelpEncodings { | ||
#expect(availableEncodings.contains(encoding), "\(String.localizedName(of: encoding))") | ||
} | ||
} | ||
} |
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,62 @@ | ||
// | ||
// FontExtensionTests.swift | ||
// Tests | ||
// | ||
// CotEditor | ||
// https://coteditor.com | ||
// | ||
// Created by 1024jp on 2016-06-10. | ||
// | ||
// --------------------------------------------------------------------------- | ||
// | ||
// © 2016-2024 1024jp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import AppKit.NSFont | ||
import Testing | ||
import Numerics | ||
@testable import CotEditor | ||
|
||
struct FontExtensionTests { | ||
|
||
@Test func fontSize() { | ||
|
||
let font = NSFont(name: "Menlo-Regular", size: 11) | ||
|
||
#expect(font?.width(of: " ") == 6.62255859375) | ||
} | ||
|
||
|
||
@Test func fontWeight() throws { | ||
|
||
let regularFont = try #require(NSFont(name: "Menlo-Regular", size: 11)) | ||
let boldFont = try #require(NSFont(name: "Menlo-Bold", size: 11)) | ||
|
||
#expect(regularFont.weight == .regular) | ||
#expect(boldFont.weight.rawValue.isApproximatelyEqual(to: NSFont.Weight.bold.rawValue, relativeTolerance: 0.00001)) | ||
|
||
// The const value is (unfortunately) not exact equal... | ||
#expect(boldFont.weight.rawValue == 0.4) | ||
#expect(NSFont.Weight.bold.rawValue != 0.4) | ||
} | ||
|
||
|
||
@Test func namedFont() throws { | ||
|
||
let avenirNextCondensed = try #require(NSFont(named: .avenirNextCondensed, weight: .bold, size: 11)) | ||
#expect(avenirNextCondensed == NSFont(name: "AvenirNextCondensed-Bold", size: 11)) | ||
#expect(avenirNextCondensed.weight.rawValue.isApproximatelyEqual(to: NSFont.Weight.bold.rawValue, relativeTolerance: 0.00001)) | ||
} | ||
} |
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,38 @@ | ||
// | ||
// FourCharCodeTests.swift | ||
// Tests | ||
// | ||
// CotEditor | ||
// https://coteditor.com | ||
// | ||
// Created by 1024jp on 2016-07-19. | ||
// | ||
// --------------------------------------------------------------------------- | ||
// | ||
// © 2016-2024 1024jp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import Testing | ||
@testable import CotEditor | ||
|
||
struct FourCharCodeTests { | ||
|
||
@Test func initialize() { | ||
|
||
#expect(FourCharCode(stringLiteral: "TEXT") == NSHFSTypeCodeFromFileType("'TEXT'")) | ||
#expect("rtfd" == NSHFSTypeCodeFromFileType("'rtfd'")) | ||
} | ||
} |
Oops, something went wrong.