Comments (5)
Errm, right, I forgot to update this issue, but I grew tired of the ASCII-only behavior so I just changed it.
ASCII-only is still useful though, so we might want an AsciiString
type or something.
from quickcheck.
Yeah, this definitely needs to be fixed. I think the ASCII limitation has been there and nobody has had cause enough to fix it.
There's basically two concerns here. The first is ergonomics. It's really nice when your witnesses are limited to characters that are likely to be meaningful in your terminal (i.e., printable characters). The second is that, of course, strings outside the ASCII range should be tested. When I first wrote quickcheck, I didn't know how to balance these so I just chose to address the first concern.
It seems like the principle of least surprise should apply here: String
should be fuzzed with the set of Unicode scalar values and some other type (perhaps defined in quickcheck, i.e., AsciiString
) should be more limited when you want a guarantee of nicer witnesses. I think it could deref to &String
, which should mostly provide the ergonomics of a plain String
.
from quickcheck.
It seems like shrinking could also come into play. I could conceive of a string with only ascii as being "smaller" than one with ascii + ascii punctuation. Then it could "grow" to include more common unicode, then "grow" towards uncommon. Just thinking outloud, really.
from quickcheck.
Has this changed? I think I saw wildly different results than this.
Just as a data point, this is what I ended up using for a string search testing / fuzzing:
#[derive(Clone, Debug)]
struct Text(String);
//static ALPHABET: &'static str = "ABCD";
static ALPHABET: &'static str = "\0\u{1}\u{2}\u{3}";
impl Arbitrary for Text {
fn arbitrary<G: qc::Gen>(g: &mut G) -> Self {
let len = u16::arbitrary(g);
let mut s = String::with_capacity(len as usize);
for _ in 0..len {
let i = usize::arbitrary(g);
let i = i % ALPHABET.len();
s.push(ALPHABET.as_bytes()[i] as char)
}
Text(s)
}
fn shrink(&self) -> Box<Iterator<Item=Self>> {
Box::new(self.0.shrink().map(Text))
}
}
Since the algorithm was working on just the byte slice, I switched to an alphabet of 0-4 for even easier to read intermediate debug outputs..
from quickcheck.
@bluss it appears so! This could be considered closed via 848acee.
from quickcheck.
Related Issues (20)
- Identity checking HOT 3
- Stack overflow in quickcheck case shrinking HOT 3
- example case sort TEST FAILED HOT 1
- QuickChecking Const Generic Code HOT 5
- Implement Arbitrary for AsMut<[T: Arbitrary]> HOT 2
- Infinite Repetition/Never Ending Test with `f32` and `f64`. HOT 17
- Q: Idiomatic way to specify the length of an arbitrary vector HOT 7
- <newbie> How to generate a number within a range HOT 2
- Negating an integer leads to stack overflow HOT 2
- upgrade notes would be nice. HOT 1
- debug_reprs taking up 41% of test runtime HOT 2
- warning: panic message is not a string literal HOT 1
- Rng Size for Vec Arbitrary cannot be 0
- Impl Clone for Gen
- Implement something like choose_weighted for `Gen`
- Is this still maintained? HOT 1
- Is quickcheck still maintained? HOT 1
- How to combine quickcheck 1+ with fake? HOT 3
- Durations's Arbitrary instance is dependant on Gen's size HOT 1
- `Logging` not working on `quickcheck` test. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quickcheck.