mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add Location struct
This commit is contained in:
parent
38f61dc74e
commit
50701ed131
2 changed files with 75 additions and 0 deletions
41
spec/spectator/core/location_spec.cr
Normal file
41
spec/spectator/core/location_spec.cr
Normal file
|
@ -0,0 +1,41 @@
|
|||
require "../../spec_helper"
|
||||
|
||||
describe Spectator::Core::Location do
|
||||
describe ".parse" do
|
||||
it "parses a location" do
|
||||
location = Spectator::Core::Location.parse("foo:10")
|
||||
location.file.should eq("foo")
|
||||
location.line?.should eq(10)
|
||||
end
|
||||
|
||||
it "parses a location with no line number" do
|
||||
location = Spectator::Core::Location.parse("foo")
|
||||
location.file.should eq("foo")
|
||||
location.line?.should be_nil
|
||||
end
|
||||
|
||||
it "parses a Windows path with a colon" do
|
||||
location = Spectator::Core::Location.parse("C:\\foo:10")
|
||||
location.file.should eq("C:\\foo")
|
||||
location.line?.should eq(10)
|
||||
end
|
||||
|
||||
it "parses a Windows path with no line number" do
|
||||
location = Spectator::Core::Location.parse("C:\\foo")
|
||||
location.file.should eq("C:\\foo")
|
||||
location.line?.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#to_s" do
|
||||
it "constructs a string representation" do
|
||||
location = Spectator::Core::Location.new("foo", 10)
|
||||
location.to_s.should eq("foo:10")
|
||||
end
|
||||
|
||||
it "constructs a string representation with no line number" do
|
||||
location = Spectator::Core::Location.new("foo")
|
||||
location.to_s.should eq("foo")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue