Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
This adds a test case from
IABTechLab/iabgpp-java#42.
This is basically an invalid example from the spec.

Also adds a test that tries to decode a TCF EU v2 string as a GPP
string, from IABTechLab/iabgpp-java#44.
  • Loading branch information
noirotm committed Apr 14, 2024
1 parent 8b865aa commit fc777c2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,27 @@ mod tests {
})
));
}

#[test]
fn non_gpp_tcfeuv2_string() {
let r = GPPString::from_str("CP48G0AP48G0AEsACCPLAkEgAAAAAEPgAB5YAAAQaQD2F2K2kKFkPCmQWYAQBCijYEAhQAAAAkCBIAAgAUgQAgFIIAgAIFAAAAAAAAAQEgCQAAQABAAAIACgAAAAAAIAAAAAAAQQAAAAAIAAAAAAAAEAAAAAAAQAAAAIAABEhCAAQQAEAAAAAAAQAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAgAA");
assert!(matches!(
r,
Err(GPPDecodeError::InvalidHeaderType { found: 2 })
));
}

#[test]
fn invalid_tcfca_section() {
let r = GPPString::from_str("DBABjw~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN")
.unwrap()
.decode_all_sections();
assert!(matches!(
r,
Err(SectionDecodeError::InvalidSegmentVersion {
expected: 1,
found: 2,
})
));
}
}

0 comments on commit fc777c2

Please sign in to comment.