#[derive(Debug, Clone, PartialEq, Eq)]
pub struct QueryScript(String);
impl QueryScript {
pub fn new(body: impl Into<String>) -> Self {
Self(body.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
#[cfg(test)]
pub mod strategy {
use super::QueryScript;
use proptest::prelude::*;
pub fn query_script() -> impl Strategy<Value = QueryScript> {
".{0,200}".prop_map(QueryScript::new)
}
}
#[cfg(test)]
mod tests {
use super::*;
use proptest::prelude::*;
proptest! {
#[test]
fn as_str_roundtrips(body in ".{0,200}") {
let s = QueryScript::new(&body);
prop_assert_eq!(s.as_str().to_string(), body);
}
}
#[test]
fn as_str_returns_the_full_body() {
let body = "?[n] := n = 1\n";
let s = QueryScript::new(body);
assert_eq!(s.as_str(), body);
}
}