2022-07-23 17:15:08 +00:00
|
|
|
defmodule MfmParser.ReaderTest do
|
|
|
|
use ExUnit.Case
|
|
|
|
alias MfmParser.Reader
|
|
|
|
|
|
|
|
test "it can peek at the next character" do
|
2022-07-24 05:55:55 +00:00
|
|
|
assert Reader.peek("chocolatine") == "c"
|
2022-07-23 17:15:08 +00:00
|
|
|
end
|
|
|
|
|
2022-07-24 23:21:02 +00:00
|
|
|
test "it can peek at the nth character" do
|
|
|
|
assert Reader.peek("chocolatine", 7) == "a"
|
|
|
|
end
|
|
|
|
|
2022-07-23 17:15:08 +00:00
|
|
|
test "it step to the next character" do
|
2022-07-24 05:55:55 +00:00
|
|
|
assert Reader.next("chocolatine") == {"c", "hocolatine"}
|
2022-07-23 17:15:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test "it returns eof" do
|
|
|
|
assert Reader.peek("") == :eof
|
2022-07-24 23:21:02 +00:00
|
|
|
assert Reader.peek("", 1) == :eof
|
|
|
|
assert Reader.peek("", 2) == :eof
|
|
|
|
assert Reader.peek("c", 3) == :eof
|
2022-07-23 17:15:08 +00:00
|
|
|
assert Reader.next("") == :eof
|
|
|
|
end
|
|
|
|
end
|