ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
use core::num::NonZeroI32;

use super::*;
use crate::primitives::mediatime::tests::range;

#[test]
fn a_range_converts_both_endpoints() {
  assert_eq!(
    range(100, 250, 1, 90_000).to_nanos(),
    Ok((1_111_111, 2_777_777))
  );
  assert_eq!(range(0, 0, 1, 1).to_nanos(), Ok((0, 0)));
}

/// `start` is converted first, so a range that overflows at both ends names its start.
#[test]
fn a_range_reports_the_start_when_both_endpoints_overflow() {
  let both = mt::TimeRange::new(
    i64::MIN,
    i64::MAX,
    mt::Timebase::new(i32::MAX, NonZeroI32::new(1).unwrap()),
  );
  let overflow = MediaTimeRange::new(both)
    .to_nanos()
    .expect_err("neither endpoint fits");

  assert!(overflow.nanos() < 0, "the start is the negative endpoint");
}

#[test]
fn a_range_reports_the_end_when_only_the_end_overflows() {
  let overflow = range(0, 1 << 62, 2, 1_000_000_000)
    .to_nanos()
    .expect_err("the end does not fit");

  assert_eq!(overflow.nanos(), 9_223_372_036_854_775_808);
}