Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

LiteralBoolean tests #38

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions python/selfie-lib/tests/LiteralBoolean_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from selfie_lib.Literals import LiteralBoolean, Language
from selfie_lib.EscapeLeadingWhitespace import EscapeLeadingWhitespace


def _encode(value: bool, expected: str):
literal_boolean = LiteralBoolean()
actual = literal_boolean.encode(
value, Language.PYTHON, EscapeLeadingWhitespace.NEVER
)
assert actual == expected, f"Expected: {expected}, Got: {actual}"


def _decode(value: str, expected: bool):
literal_boolean = LiteralBoolean()
actual = literal_boolean.parse(value, Language.PYTHON)
assert actual == expected, f"Expected: {expected}, Got: {actual}"


class TestLiteralBoolean:
def test_encode(self):
_encode(True, "True")
_encode(False, "False")

def test_decode(self):
_decode("true", True)
_decode("false", False)