Skip to content

Commit

Permalink
replace eprintln with log::trace
Browse files Browse the repository at this point in the history
  • Loading branch information
pchampin committed Jun 26, 2024
1 parent 675fb9c commit 0dee54d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ sophia_turtle = { version = "0.8.0", path = "./turtle" }
sophia_xml = { version = "0.8.0", path = "./xml" }

criterion = "0.5"
env_logger = "0.11.3"
futures-util = "0.3.28"
lazy_static = "1.4.0"
log = "0.4.21"
mownstr = "0.2.1"
oxiri = "0.2.2"
regex = "1.6.0"
Expand Down
6 changes: 5 additions & 1 deletion c14n/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ keywords.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
log.workspace = true
sha2 = "0.10.7"
sophia_api.workspace = true
sophia_iri.workspace = true
thiserror.workspace = true
thiserror.workspace = true

[dev-dependencies]
env_logger.workspace = true
14 changes: 14 additions & 0 deletions c14n/src/_permutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ mod test {

#[test]
fn check_empty() {
crate::test_setup();

let mut a = [];
let mut got = HashSet::<Vec<i32>>::new();
for_each_permutation_of(&mut a, |a| {
Expand All @@ -49,6 +51,8 @@ mod test {

#[test]
fn check_1() {
crate::test_setup();

let mut a = [1];
let exp = [vec![1]].into_iter().collect::<HashSet<_>>();
let mut got = HashSet::<Vec<i32>>::new();
Expand All @@ -62,6 +66,8 @@ mod test {

#[test]
fn check_12() {
crate::test_setup();

let mut a = [1, 2];
let exp = [vec![1, 2], vec![2, 1]].into_iter().collect::<HashSet<_>>();
let mut got = HashSet::<Vec<i32>>::new();
Expand All @@ -75,6 +81,8 @@ mod test {

#[test]
fn check_123() {
crate::test_setup();

let mut a = [1, 2, 3];
let exp = [
vec![1, 2, 3],
Expand All @@ -97,6 +105,8 @@ mod test {

#[test]
fn check_1234() {
crate::test_setup();

let mut a = [1, 2, 3, 4];
let exp = [
vec![1, 2, 3, 4],
Expand Down Expand Up @@ -137,6 +147,8 @@ mod test {

#[test]
fn check_12345() {
crate::test_setup();

let mut a = [1, 2, 3, 4, 5];
let mut got = HashSet::<Vec<i32>>::new();
for_each_permutation_of(&mut a, |a| {
Expand All @@ -149,6 +161,8 @@ mod test {

#[test]
fn check_err() {
crate::test_setup();

let mut a = [1, 2, 3, 4];
let exp = [
vec![1, 2, 3, 4],
Expand Down
10 changes: 10 additions & 0 deletions c14n/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ pub enum C14nError<E: std::error::Error> {
#[error("Unsupported feature: {0}")]
Unsupported(String),
}

#[cfg(test)]
fn test_setup() {
TEST_SETUP.call_once(|| {
env_logger::init();
});
}

#[cfg(test)]
static TEST_SETUP: std::sync::Once = std::sync::Once::new();
22 changes: 20 additions & 2 deletions c14n/src/rdfc10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ impl<'a, H: HashFunction, T: Term> C14nState<'a, H, T> {
ret_issuer.unwrap_or_else(|| issuer.clone()),
);
debug_assert!({
eprintln!(
log::trace!(
"hash-n-degree({}, {})\n-> {}",
identifier,
depth,
Expand Down Expand Up @@ -470,7 +470,7 @@ fn hash_first_degree_quads<H: HashFunction, Q: Quad>(bnid: &str, quads: &[&Q]) -
}
let ret = hasher.finalize();
debug_assert!({
eprintln!("hash-first-degree({})\n-> {}", bnid, hex(&ret));
log::trace!("hash-first-degree({})\n-> {}", bnid, hex(&ret));
true
});
ret
Expand Down Expand Up @@ -520,6 +520,8 @@ mod test {

#[test]
fn example2() {
crate::test_setup();

let dataset = ez_quads(&[
"<http://example.com/#p> <http://example.com/#q> _:e0 .",
"<http://example.com/#p> <http://example.com/#r> _:e1 .",
Expand All @@ -538,6 +540,8 @@ _:c14n1 <http://example.com/#t> <http://example.com/#u> .

#[test]
fn example3() {
crate::test_setup();

let dataset = ez_quads(&[
"<http://example.com/#p> <http://example.com/#q> _:e0 .",
"<http://example.com/#p> <http://example.com/#q> _:e1 .",
Expand All @@ -558,6 +562,8 @@ _:c14n3 <http://example.com/#p> _:c14n0 .

#[test]
fn cycle5() {
crate::test_setup();

let dataset = ez_quads(&[
"_:e0 <http://example.com/#p> _:e1 .",
"_:e1 <http://example.com/#p> _:e2 .",
Expand All @@ -578,6 +584,8 @@ _:c14n4 <http://example.com/#p> _:c14n3 .

#[test]
fn cycle5_toxic() {
crate::test_setup();

let dataset = ez_quads(&[
"_:e0 <http://example.com/#p> _:e1 .",
"_:e1 <http://example.com/#p> _:e2 .",
Expand All @@ -598,6 +606,8 @@ _:c14n4 <http://example.com/#p> _:c14n3 .

#[test]
fn clique5() {
crate::test_setup();

let dataset = ez_quads(&[
"_:e0 <http://example.com/#p> _:e1 .",
"_:e0 <http://example.com/#p> _:e2 .",
Expand Down Expand Up @@ -648,6 +658,8 @@ _:c14n4 <http://example.com/#p> _:c14n3 .

#[test]
fn clique5_toxic() {
crate::test_setup();

let dataset = ez_quads(&[
"_:e0 <http://example.com/#p> _:e1 .",
"_:e0 <http://example.com/#p> _:e2 .",
Expand Down Expand Up @@ -679,6 +691,8 @@ _:c14n4 <http://example.com/#p> _:c14n3 .

#[test]
fn cycle2plus3() {
crate::test_setup();

let dataset = ez_quads(&[
"_:e0 <http://example.com/#p> _:e1 .",
"_:e1 <http://example.com/#p> _:e0 .",
Expand All @@ -699,6 +713,8 @@ _:c14n4 <http://example.com/#p> _:c14n3 .

#[test]
fn tricky_order() {
crate::test_setup();

let dataset = ez_quads(&[
"<tag:a> <tag:p> _:a .",
"<tag:a> <tag:p> <tag:a> .",
Expand Down Expand Up @@ -780,6 +796,8 @@ _:c14n4 <http://example.com/#p> _:c14n3 .

#[test]
fn example2_sha384() {
crate::test_setup();

let dataset = ez_quads(&[
"<http://example.com/#p> <http://example.com/#q> _:e0 .",
"<http://example.com/#p> <http://example.com/#r> _:e1 .",
Expand Down

0 comments on commit 0dee54d

Please sign in to comment.