blob: 2b77de61875590fd254fcfc998cc386024579d7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
use ron::de::{from_str, Error, Position, SpannedError as RonErr};
#[test]
fn test_simple() {
assert_eq!(
from_str(
"/*
* We got a hexadecimal number here!
*
*/0x507"
),
Ok(0x507)
);
}
#[test]
fn test_nested() {
assert_eq!(
from_str(
"/*
/* quite * some * nesting * going * on * /* here /* (yeah, maybe a bit too much) */ */ */
*/
// The actual value comes.. /*
// very soon, these are just checks that */
// multi-line comments don't trigger in line comments /*
\"THE VALUE\" /* This is the value /* :) */ */
"
),
Ok("THE VALUE".to_owned())
);
}
#[test]
fn test_unclosed() {
assert_eq!(
from_str::<String>(
"/*
/* quite * some * nesting * going * on * /* here /* (yeah, maybe a bit too much) */ */ */
*/
// The actual value comes.. /*
// very soon, these are just checks that */
// multi-line comments don't trigger in line comments /*
/* Unfortunately, this comment won't get closed :(
\"THE VALUE (which is invalid)\"
"
),
Err(RonErr {
code: Error::UnclosedBlockComment,
position: Position { col: 1, line: 9 }
})
);
}
|