//! Round-trip integration test: encode → decode → assert equality.

#[test]
fn bzip2_round_trip_small() {
    use crate::tests::fixtures;
    let input = fixtures::random_seeded(1024);
    let compressed = crate::encode(&input, 6).expect("encode");
    let decompressed = crate::decode(&compressed).expect("decode");
    assert_eq!(input, decompressed, "round-trip must be byte-identical");
}

#[test]
fn bzip2_round_trip_64k() {
    use crate::tests::fixtures;
    let input = fixtures::random_seeded(64 * 1024);
    let compressed = crate::encode(&input, 6).expect("encode");
    let decompressed = crate::decode(&compressed).expect("decode");
    assert_eq!(input, decompressed, "round-trip must be byte-identical");
}

#[test]
fn bzip2_zeros_compresses_well() {
    use crate::tests::fixtures;
    let input = fixtures::zeros(1024 * 1024);
    let compressed = crate::encode(&input, 6).expect("encode");
    let decompressed = crate::decode(&compressed).expect("decode");
    assert_eq!(input, decompressed, "round-trip must be byte-identical");
    assert!(
        compressed.len() < input.len() / 100,
        "BZip2 should compress 1 MiB of zeros heavily; got {} bytes",
        compressed.len()
    );
}
