current status
This commit is contained in:
67
const_test.py
Normal file
67
const_test.py
Normal file
@@ -0,0 +1,67 @@
|
||||
import pytest
|
||||
|
||||
|
||||
|
||||
from const import gray_1d
|
||||
|
||||
# Happy path tests with various realistic test values
|
||||
@pytest.mark.parametrize("k, symbol, expected", [
|
||||
(0, 0, 0), # k=0 case
|
||||
(1, 0, 1), # k=1, symbol=0 case
|
||||
(1, 1, -1), # k=1, symbol=1 case
|
||||
(2, 0, 3), # k=2, symbol=0 case
|
||||
(2, 1, 1), # k=2, symbol=1 case
|
||||
(2, 2, -3), # k=2, symbol=2 case
|
||||
(2, 3, -1), # k=2, symbol=3 case
|
||||
], ids=[
|
||||
"k=0_symbol=0",
|
||||
"k=1_symbol=0",
|
||||
"k=1_symbol=1",
|
||||
"k=2_symbol=0",
|
||||
"k=2_symbol=1",
|
||||
"k=2_symbol=2",
|
||||
"k=2_symbol=3"
|
||||
])
|
||||
def test_gray_1d_happy_path(k, symbol, expected):
|
||||
# Act
|
||||
result = gray_1d(k, symbol)
|
||||
|
||||
# Assert
|
||||
assert result == expected
|
||||
|
||||
# Various edge cases
|
||||
@pytest.mark.parametrize("k, symbol, expected", [
|
||||
(3, 0, 7), # k=3, symbol=0 case
|
||||
(3, 7, -3), # k=3, symbol=7 case
|
||||
(4, 0, 15), # k=4, symbol=0 case
|
||||
(4, 15, -5), # k=4, symbol=15 case
|
||||
], ids=[
|
||||
"k=3_symbol=0",
|
||||
"k=3_symbol=7",
|
||||
"k=4_symbol=0",
|
||||
"k=4_symbol=15"
|
||||
])
|
||||
def test_gray_1d_edge_cases(k, symbol, expected):
|
||||
# Act
|
||||
result = gray_1d(k, symbol)
|
||||
|
||||
# Assert
|
||||
assert result == expected
|
||||
|
||||
# Various error cases
|
||||
@pytest.mark.parametrize("k, symbol, exception", [
|
||||
(-1, 0, ValueError), # k is negative
|
||||
(1, -1, ValueError), # symbol is negative
|
||||
(1, 2, ValueError), # symbol is out of range for k=1
|
||||
(2, 4, ValueError), # symbol is out of range for k=2
|
||||
], ids=[
|
||||
"k_negative",
|
||||
"symbol_negative",
|
||||
"symbol_out_of_range_k1",
|
||||
"symbol_out_of_range_k2"
|
||||
])
|
||||
def test_gray_1d_error_cases(k, symbol, exception):
|
||||
# Act and Assert
|
||||
with pytest.raises(exception):
|
||||
gray_1d(k, symbol)
|
||||
|
||||
Reference in New Issue
Block a user