Fixes a bug in xsd:gYear parsing

pull/51/head
Tpt 4 years ago
parent b101ae1c54
commit cf67bda446
  1. 2
      CHANGELOG.md
  2. 45
      lib/src/model/xsd/date_time.rs
  3. 3
      lib/src/model/xsd/parser.rs

@ -4,7 +4,7 @@
- `QueryOptions::with_default_graph` now takes an `impl Into<GraphName>` instead of an `impl Into<NamedNode>`. - `QueryOptions::with_default_graph` now takes an `impl Into<GraphName>` instead of an `impl Into<NamedNode>`.
- `QueryOptions::with_named_graph` now takes an `impl Into<NamedOrBlankNode>` instead of an `impl Into<NamedNode>`. - `QueryOptions::with_named_graph` now takes an `impl Into<NamedOrBlankNode>` instead of an `impl Into<NamedNode>`.
- `pyoxigraph` `query` methods now takes two new parameters, `default_graph` and `named_graphs`. `default_graph_uris` and `named_graph_uris` parameters are deprecated. - `pyoxigraph` `query` methods now takes two new parameters, `default_graph` and `named_graphs`. `default_graph_uris` and `named_graph_uris` parameters are deprecated.
- Fixes a bug in `xsd:gYear` parsing.
## [0.1.0] - 2020-08-09 ## [0.1.0] - 2020-08-09

@ -1813,6 +1813,51 @@ mod tests {
Time::from_str("23:00:00-03:00").unwrap(), Time::from_str("23:00:00-03:00").unwrap(),
Time::from_str("02:00:00Z").unwrap() Time::from_str("02:00:00Z").unwrap()
); );
assert_ne!(
GYearMonth::from_str("1986-02").unwrap(),
GYearMonth::from_str("1986-03").unwrap()
);
assert_ne!(
GYearMonth::from_str("1978-03").unwrap(),
GYearMonth::from_str("1978-03Z").unwrap()
);
assert_ne!(
GYear::from_str("2005-12:00").unwrap(),
GYear::from_str("2005+12:00").unwrap()
);
assert_ne!(
GYear::from_str("1976-05:00").unwrap(),
GYear::from_str("1976").unwrap()
);
assert_eq!(
GMonthDay::from_str("--12-25-14:00").unwrap(),
GMonthDay::from_str("--12-26+10:00").unwrap()
);
assert_ne!(
GMonthDay::from_str("--12-25").unwrap(),
GMonthDay::from_str("--12-26Z").unwrap()
);
assert_ne!(
GMonth::from_str("--12-14:00").unwrap(),
GMonth::from_str("--12+10:00").unwrap()
);
assert_ne!(
GMonth::from_str("--12").unwrap(),
GMonth::from_str("--12Z").unwrap()
);
assert_ne!(
GDay::from_str("---25-14:00").unwrap(),
GDay::from_str("---25+10:00").unwrap()
);
assert_ne!(
GDay::from_str("---12").unwrap(),
GDay::from_str("---12Z").unwrap()
);
} }
#[test] #[test]

@ -1,6 +1,6 @@
use super::*; use super::*;
use nom::branch::alt; use nom::branch::alt;
use nom::bytes::complete::{tag, take_while}; use nom::bytes::complete::{tag, take_while, take_while_m_n};
use nom::character::complete::{char, digit0, digit1}; use nom::character::complete::{char, digit0, digit1};
use nom::combinator::{map, opt, recognize}; use nom::combinator::{map, opt, recognize};
use nom::error::{ErrorKind, ParseError}; use nom::error::{ErrorKind, ParseError};
@ -14,7 +14,6 @@ use super::date_time::DateTimeError;
use super::decimal::ParseDecimalError; use super::decimal::ParseDecimalError;
use crate::model::xsd::date_time::{GDay, GMonth, GMonthDay, GYear, GYearMonth, TimezoneOffset}; use crate::model::xsd::date_time::{GDay, GMonth, GMonthDay, GYear, GYearMonth, TimezoneOffset};
use crate::model::xsd::duration::{DayTimeDuration, YearMonthDuration}; use crate::model::xsd::duration::{DayTimeDuration, YearMonthDuration};
use nom::bytes::streaming::take_while_m_n;
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
use std::num::ParseIntError; use std::num::ParseIntError;

Loading…
Cancel
Save