Skip to content

Commit

Permalink
docs: update example demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
zachallaun committed Jul 17, 2024
1 parent 2ba36c5 commit 4c05526
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
defmodule LRCPCorrect do
defmodule LRCP do
@moduledoc """
Parser for the ficticious Protohackers "Line Reversal Control Protocol".
For more, see here: https://protohackers.com/problem/7
"""

def parse("/data/" <> rest) do
with {:ok, session, rest} <- parse_integer(rest),
{:ok, position, rest} <- parse_integer(rest),
Expand All @@ -11,9 +17,8 @@ defmodule LRCPCorrect do
end

def parse("/connect/" <> rest) do
with {:ok, session, ""} <- parse_integer(rest) do
{:ok, {:connect, session: session}}
else
case parse_integer(rest) do
{:ok, session, ""} -> {:ok, {:connect, session: session}}
{:ok, _, rest} -> {:error, rest}
error -> error
end
Expand All @@ -30,9 +35,8 @@ defmodule LRCPCorrect do
end

def parse("/close/" <> rest) do
with {:ok, session, ""} <- parse_integer(rest) do
{:ok, {:close, session: session}}
else
case parse_integer(rest) do
{:ok, session, ""} -> {:ok, {:close, session: session}}
{:ok, _, rest} -> {:error, rest}
error -> error
end
Expand Down
2 changes: 0 additions & 2 deletions examples/demo_project/test/lrcp_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ defmodule LRCPTest do
use Mneme, dry_run: true

describe "parse/1" do
alias LRCPCorrect, as: LRCP

@tag :first_example
test "parses valid messages (1)" do
auto_assert LRCP.parse("/connect/12345/")
Expand Down

0 comments on commit 4c05526

Please sign in to comment.