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

Commit

Permalink
LiteralBoolean tests (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Mar 14, 2024
2 parents eb4560c + 961de07 commit a9c17e8
Showing 1 changed file with 26 additions and 0 deletions.
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)

0 comments on commit a9c17e8

Please sign in to comment.