2015-01-15 14:44:05 -06:00
|
|
|
extern crate toml;
|
|
|
|
|
|
|
|
use toml::{Parser};
|
2014-06-20 19:01:38 -05:00
|
|
|
|
|
|
|
fn run(toml: &str) {
|
|
|
|
let mut p = Parser::new(toml);
|
|
|
|
let table = p.parse();
|
|
|
|
assert!(table.is_none());
|
2015-01-15 21:47:14 -06:00
|
|
|
assert!(p.errors.len() > 0);
|
2014-06-20 19:01:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! test( ($name:ident, $toml:expr) => (
|
|
|
|
#[test]
|
|
|
|
fn $name() { run($toml); }
|
2014-12-18 15:48:34 -06:00
|
|
|
) );
|
2014-06-20 19:01:38 -05:00
|
|
|
|
|
|
|
test!(array_mixed_types_arrays_and_ints,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/array-mixed-types-arrays-and-ints.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(array_mixed_types_ints_and_floats,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/array-mixed-types-ints-and-floats.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(array_mixed_types_strings_and_ints,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/array-mixed-types-strings-and-ints.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(datetime_malformed_no_leads,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/datetime-malformed-no-leads.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(datetime_malformed_no_secs,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/datetime-malformed-no-secs.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(datetime_malformed_no_t,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/datetime-malformed-no-t.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(datetime_malformed_no_z,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/datetime-malformed-no-z.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(datetime_malformed_with_milli,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/datetime-malformed-with-milli.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(duplicate_keys,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/duplicate-keys.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(duplicate_key_table,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/duplicate-key-table.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(duplicate_tables,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/duplicate-tables.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(empty_implicit_table,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/empty-implicit-table.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(empty_table,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/empty-table.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(float_no_leading_zero,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/float-no-leading-zero.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(float_no_trailing_digits,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/float-no-trailing-digits.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(key_two_equals,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/key-two-equals.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(string_bad_byte_escape,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/string-bad-byte-escape.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(string_bad_escape,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/string-bad-escape.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(string_byte_escapes,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/string-byte-escapes.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(string_no_close,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/string-no-close.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(table_array_implicit,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/table-array-implicit.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(table_array_malformed_bracket,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/table-array-malformed-bracket.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(table_array_malformed_empty,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/table-array-malformed-empty.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(table_nested_brackets_close,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/table-nested-brackets-close.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(table_nested_brackets_open,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/table-nested-brackets-open.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(text_after_array_entries,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/text-after-array-entries.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(text_after_integer,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/text-after-integer.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(text_after_string,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/text-after-string.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(text_after_table,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/text-after-table.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(text_before_array_separator,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/text-before-array-separator.toml"));
|
2014-06-20 19:01:38 -05:00
|
|
|
test!(text_in_array,
|
2014-12-18 15:48:34 -06:00
|
|
|
include_str!("invalid/text-in-array.toml"));
|