import numpy as np
import pytest
import ganz

def test_unpack_bits():
    dna = ganz.DnaSequence("ACGT")
    bits = dna.unpack_bits()
    
    expected = np.array([
        [1, 0, 0, 0],  # A
        [0, 1, 0, 0],  # C
        [0, 0, 1, 0],  # G
        [0, 0, 0, 1],  # T
    ])
    
    np.testing.assert_array_equal(bits, expected)

def test_unpack_bits_longer():
    dna = ganz.DnaSequence("ACGTACGT")
    bits = dna.unpack_bits()
    
    expected = np.array([
        [1, 0, 0, 0],  # A
        [0, 1, 0, 0],  # C
        [0, 0, 1, 0],  # G
        [0, 0, 0, 1],  # T
        [1, 0, 0, 0],  # A
        [0, 1, 0, 0],  # C
        [0, 0, 1, 0],  # G
        [0, 0, 0, 1],  # T
    ])
    
    np.testing.assert_array_equal(bits, expected)

def test_invalid_sequence():
    dna = ganz.DnaSequence("ACGN")
    bits = dna.unpack_bits()
    
    expected = np.array([
        [1, 0, 0, 0],  # A
        [0, 1, 0, 0],  # C
        [0, 0, 1, 0],  # G
        [0, 0, 0, 0],  # N
    ])
    
    np.testing.assert_array_equal(bits, expected)

def test_long_sequence():
    seq = "ACGTACGTACGT"  # 12 nucleotides
    dna = ganz.DnaSequence(seq)
    assert len(dna) == 12
    assert str(dna) == seq
    
def test_odd_length_sequence():
    seq = "ACGTACGTACG"  # 11 nucleotides
    dna = ganz.DnaSequence(seq)
    assert len(dna) == 11
    assert str(dna) == seq 