~matthiasbeyer/serde-select

dc4c5a3fdd0f01d331e9e53ed4038e4653f5bea1 — Matthias Beyer 4 years ago 376a292
Setup logging in tests

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
3 files changed, 34 insertions(+), 0 deletions(-)

M Cargo.toml
M src/lib.rs
M src/resolver.rs
M Cargo.toml => Cargo.toml +1 -0
@@ 30,6 30,7 @@ toml         = "0.5"
serde_json   = "1"
quickcheck   = "0.8"
serde_derive = "1"
env_logger   = "0.7"

[features]
default = ["backend_toml", "backend_serde_json"]

M src/lib.rs => src/lib.rs +2 -0
@@ 8,6 8,8 @@
#[macro_use] extern crate quickcheck;
#[cfg(test)]
#[macro_use] extern crate serde_derive;
#[cfg(test)]
#[macro_use] extern crate env_logger;

pub mod error;
pub mod object;

M src/resolver.rs => src/resolver.rs +31 -0
@@ 63,6 63,10 @@ mod test {
    use toml::from_str as toml_from_str;
    use toml::Value;

    fn setup_logging() {
        let _ = env_logger::try_init();
    }

    macro_rules! do_resolve {
        ( $toml:ident => $query:expr ) => {
            resolve(


@@ 75,6 79,7 @@ mod test {

    #[test]
    fn test_resolve_empty_toml_simple_query() {
        setup_logging();
        let toml : toml::Value = toml_from_str("").unwrap();
        let result = do_resolve!(toml => "example");



@@ 86,6 91,7 @@ mod test {

    #[test]
    fn test_resolve_present_bool() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = true").unwrap();
        let result = do_resolve!(toml => "example");



@@ 100,6 106,7 @@ mod test {

    #[test]
    fn test_resolve_present_integer() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = 1").unwrap();
        let result = do_resolve!(toml => "example");



@@ 114,6 121,7 @@ mod test {

    #[test]
    fn test_resolve_present_float() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = 1.0").unwrap();
        let result = do_resolve!(toml => "example");



@@ 129,6 137,7 @@ mod test {

    #[test]
    fn test_resolve_present_string() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = 'string'").unwrap();
        let result = do_resolve!(toml => "example");



@@ 147,6 156,7 @@ mod test {

    #[test]
    fn test_resolve_present_array_bools() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = [ true, false ]").unwrap();
        let result = do_resolve!(toml => "example");



@@ 168,6 178,7 @@ mod test {

    #[test]
    fn test_resolve_present_array_integers() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = [ 1, 1337 ]").unwrap();
        let result = do_resolve!(toml => "example");



@@ 189,6 200,7 @@ mod test {

    #[test]
    fn test_resolve_present_array_floats() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = [ 1.0, 133.25 ]").unwrap();
        let result = do_resolve!(toml => "example");



@@ 212,6 224,7 @@ mod test {

    #[test]
    fn test_resolve_array_index_query_1() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = [ 1 ]").unwrap();
        let result = do_resolve!(toml => "example.[0]");



@@ 226,6 239,7 @@ mod test {

    #[test]
    fn test_resolve_array_index_query_2() {
        setup_logging();
        let toml: toml::Value = toml_from_str("example = [ 1, 2, 3, 4, 5 ]").unwrap();
        let result = do_resolve!(toml => "example.[4]");



@@ 240,6 254,7 @@ mod test {

    #[test]
    fn test_resolve_table_element_query() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [table]


@@ 260,6 275,7 @@ mod test {

    #[test]
    fn test_resolve_table_with_many_elements_element_query() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [table]


@@ 284,6 300,7 @@ mod test {

    #[test]
    fn test_resolve_table_array_query() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [table]


@@ 313,6 330,7 @@ mod test {

    #[test]
    fn test_resolve_table_array_element_query() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [table]


@@ 333,6 351,7 @@ mod test {

    #[test]
    fn test_resolve_multi_table_query() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [table0]


@@ 379,6 398,7 @@ mod test {

    #[test]
    fn test_resolve_array_table_query_1() {
        setup_logging();
        let toml: toml::Value = toml_from_str(FRUIT_TABLE).unwrap();
        let result = do_resolve!(toml => "fruit.blah.[0].name");



@@ 397,6 417,7 @@ mod test {

    #[test]
    fn test_resolve_array_table_query_2() {
        setup_logging();
        let toml: toml::Value = toml_from_str(FRUIT_TABLE).unwrap();
        let result = do_resolve!(toml => "fruit.blah.[0].physical");



@@ 424,6 445,7 @@ mod test {

    #[test]
    fn test_resolve_query_on_result() {
        setup_logging();
        let toml: toml::Value = toml_from_str(FRUIT_TABLE).unwrap();
        let result = do_resolve!(toml => "fruit.blah.[1].physical");



@@ 451,6 473,7 @@ mod test {

    #[test]
    fn test_resolve_query_empty_table() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]


@@ 474,6 497,7 @@ mod test {

    #[test]
    fn test_resolve_query_member_of_empty_table() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]


@@ 490,6 514,7 @@ mod test {

    #[test]
    fn test_resolve_query_index_in_table() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]


@@ 506,6 531,7 @@ mod test {

    #[test]
    fn test_resolve_query_identifier_in_array() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]


@@ 523,6 549,7 @@ mod test {

    #[test]
    fn test_resolve_query_value_as_table() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]


@@ 540,6 567,7 @@ mod test {

    #[test]
    fn test_resolve_query_value_as_array() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]


@@ 557,6 585,7 @@ mod test {

    #[test]
    fn test_indexing_out_of_bounds() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]


@@ 574,6 603,7 @@ mod test {

    #[test]
    fn test_indexing_out_of_bounds_edgecase_1() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]


@@ 591,6 621,7 @@ mod test {

    #[test]
    fn test_indexing_out_of_bounds_edgecase_2() {
        setup_logging();
        let toml: toml::Value = toml_from_str(
            r#"
        [example]