Skip to content

Commit fb4911f

Browse files
committed
Add more tests
1 parent 7c6dd08 commit fb4911f

File tree

6 files changed

+75
-6
lines changed

6 files changed

+75
-6
lines changed

Core/.swiftpm/xcode/xcshareddata/xcschemes/Core-Package.xcscheme

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
shouldUseLaunchSchemeArgsEnv = "YES"
30-
shouldAutocreateTestPlan = "YES">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<TestPlans>
31+
<TestPlanReference
32+
reference = "container:../TestPlan.xctestplan"
33+
default = "YES">
34+
</TestPlanReference>
35+
</TestPlans>
3136
</TestAction>
3237
<LaunchAction
3338
buildConfiguration = "Debug"

Core/Package.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ let package = Package(
6565
.product(name: "Parsing", package: "swift-parsing"),
6666
]
6767
),
68+
69+
.testTarget(
70+
name: "FundamentalTests",
71+
dependencies: ["Fundamental"]
72+
),
6873
.testTarget(
6974
name: "SuggestionServiceTests",
7075
dependencies: ["SuggestionService"]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import CopilotForXcodeKit
2+
import XCTest
3+
4+
@testable import Fundamental
5+
6+
class ConvertRangeTests: XCTestCase {
7+
func test_convert_range_0_0() {
8+
XCTAssertEqual(
9+
convertRangeToCursorRange(0...0, in: "\n".breakLines()),
10+
CursorRange(start: .zero, end: .init(line: 0, character: 0))
11+
)
12+
}
13+
14+
func test_convert_range_same_line() {
15+
XCTAssertEqual(
16+
convertRangeToCursorRange(1...5, in: "123456789\n".breakLines()),
17+
CursorRange(start: .init(line: 0, character: 1), end: .init(line: 0, character: 5))
18+
)
19+
}
20+
21+
func test_convert_range_multiple_line() {
22+
XCTAssertEqual(
23+
convertRangeToCursorRange(5...25, in: "123456789\n123456789\n123456789\n".breakLines()),
24+
CursorRange(start: .init(line: 0, character: 5), end: .init(line: 2, character: 5))
25+
)
26+
}
27+
28+
func test_convert_range_all_line() {
29+
XCTAssertEqual(
30+
convertRangeToCursorRange(0...29, in: "123456789\n123456789\n123456789\n".breakLines()),
31+
CursorRange(start: .init(line: 0, character: 0), end: .init(line: 2, character: 9))
32+
)
33+
}
34+
35+
func test_convert_range_out_of_range() {
36+
XCTAssertEqual(
37+
convertRangeToCursorRange(0...70, in: "123456789\n123456789\n123456789\n".breakLines()),
38+
CursorRange(start: .init(line: 0, character: 0), end: .init(line: 3, character: 0))
39+
)
40+
}
41+
}
42+

CustomSuggestionService.xcodeproj/xcshareddata/xcschemes/CopilotForXcodeExtension.xcscheme

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@
4141
buildConfiguration = "Debug"
4242
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4343
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44-
shouldUseLaunchSchemeArgsEnv = "YES"
45-
shouldAutocreateTestPlan = "YES">
44+
shouldUseLaunchSchemeArgsEnv = "YES">
45+
<TestPlans>
46+
<TestPlanReference
47+
reference = "container:TestPlan.xctestplan"
48+
default = "YES">
49+
</TestPlanReference>
50+
</TestPlans>
4651
</TestAction>
4752
<LaunchAction
4853
buildConfiguration = "Debug"

CustomSuggestionService.xcodeproj/xcshareddata/xcschemes/CustomSuggestionService.xcscheme

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
shouldUseLaunchSchemeArgsEnv = "YES"
30-
shouldAutocreateTestPlan = "YES">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<TestPlans>
31+
<TestPlanReference
32+
reference = "container:TestPlan.xctestplan"
33+
default = "YES">
34+
</TestPlanReference>
35+
</TestPlans>
3136
</TestAction>
3237
<LaunchAction
3338
buildConfiguration = "Debug"

TestPlan.xctestplan

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
"identifier" : "SuggestionServiceTests",
1919
"name" : "SuggestionServiceTests"
2020
}
21+
},
22+
{
23+
"target" : {
24+
"containerPath" : "container:Core",
25+
"identifier" : "FundamentalTests",
26+
"name" : "FundamentalTests"
27+
}
2128
}
2229
],
2330
"version" : 1

0 commit comments

Comments
 (0)