Skip to content

Commit 0e6351b

Browse files
author
andrew
committed
Bread yaml, random tests, readme fixes
1 parent be5283e commit 0e6351b

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

.bread.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
!v1
2+
weights:
3+
accounts:
4+
1: 100
5+
projects:
6+
https://github.com/LukasKalbertodt/litrs/: 100
7+
https://github.com/dtolnay/anyhow: 100
8+
https://github.com/dtolnay/proc-macro2: 100
9+
https://github.com/dtolnay/quote: 100
10+
https://github.com/dtolnay/syn: 100
11+
https://github.com/matklad/once_cell: 100
12+
https://github.com/rust-lang/regex: 100

readme.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,3 @@ As noted above, not much type available so only the structure above can be check
6363
I was hoping to be able to ensure that the regex has valid characters for numbers, but due to the above and the difficulty of reasoning about the contents of regex ASTs I had to scrap that.
6464

6565
Non-unicode parsing isn't currently supported. I couldn't find an ascii float parsing library and this isn't maximally optimized in the first place due to the use of `anyhow`. If this is important and you have a vision of how it could work please raise an issue!
66-
67-
The parse returns a Result, not an Option, in the case of a non-match. This is because a non-match and

tests/test.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,42 @@ fn match_() {
1111
assert_eq!(v.0, "a");
1212
assert_eq!(v.1, 44);
1313
}
14+
15+
#[cfg(feature = "unicode")]
16+
#[test]
17+
fn named() {
18+
#[structre("(?P<a>a)(?P<b>44)")]
19+
struct Parsed {
20+
a: String,
21+
b: u32,
22+
}
23+
24+
let pre = ParsedFromRegex::new();
25+
let v = pre.parse("a44").unwrap();
26+
assert_eq!(v.a, "a");
27+
assert_eq!(v.b, 44);
28+
}
29+
30+
#[cfg(feature = "unicode")]
31+
#[test]
32+
fn uncapture() {
33+
#[structre("(?:(a))")]
34+
struct Parsed(String);
35+
36+
let pre = ParsedFromRegex::new();
37+
let v = pre.parse("a").unwrap();
38+
assert_eq!(v.0, "a");
39+
}
40+
41+
#[cfg(feature = "unicode")]
42+
#[test]
43+
fn uncapture_named() {
44+
#[structre("(?:(?P<a>a))")]
45+
struct Parsed {
46+
a: String,
47+
}
48+
49+
let pre = ParsedFromRegex::new();
50+
let v = pre.parse("a").unwrap();
51+
assert_eq!(v.a, "a");
52+
}

0 commit comments

Comments
 (0)