mirror of
https://github.com/Quad4-Software/MeshChatX.git
synced 2026-08-18 09:49:09 -04:00
23 lines
630 B
Python
23 lines
630 B
Python
# SPDX-License-Identifier: 0BSD
|
|
|
|
import pytest
|
|
|
|
from meshchatx.src.backend.colour_utils import ColourUtils
|
|
|
|
|
|
def test_hex_colour_to_byte_array():
|
|
# Test with # prefix
|
|
hex_val = "#FF00AA"
|
|
expected = bytes.fromhex("FF00AA")
|
|
assert ColourUtils.hex_colour_to_byte_array(hex_val) == expected
|
|
|
|
# Test without # prefix
|
|
hex_val = "00BBFF"
|
|
expected = bytes.fromhex("00BBFF")
|
|
assert ColourUtils.hex_colour_to_byte_array(hex_val) == expected
|
|
|
|
|
|
def test_hex_colour_to_byte_array_invalid():
|
|
# Test with invalid hex
|
|
with pytest.raises(ValueError):
|
|
ColourUtils.hex_colour_to_byte_array("#GG00AA")
|