-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ImaMapleTree/feature/remove-method-property
Remove Method Property
- Loading branch information
Showing
13 changed files
with
372 additions
and
287 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use derive_ctor::ctor; | ||
|
||
#[derive(ctor, Debug, PartialEq)] | ||
pub struct Unit; | ||
|
||
#[test] | ||
fn test_unit_struct() { | ||
let unit = Unit::new(); | ||
assert_eq!(Unit, unit); | ||
} | ||
|
||
#[derive(ctor, Debug, PartialEq)] | ||
pub struct Empty {} | ||
|
||
#[test] | ||
fn test_empty_struct_no_config() { | ||
let empty = Empty::new(); | ||
assert_eq!(Empty { }, empty) | ||
} | ||
|
||
#[derive(ctor, Debug, PartialEq)] | ||
pub struct OneFieldStruct { | ||
value: u32 | ||
} | ||
|
||
#[test] | ||
fn test_struct_with_field() { | ||
let ofs = OneFieldStruct::new(300); | ||
assert_eq!(OneFieldStruct { value: 300 }, ofs) | ||
} | ||
|
||
#[derive(ctor, Debug, PartialEq)] | ||
pub struct ManyFieldStruct { | ||
value1: u32, | ||
value2: bool | ||
} | ||
|
||
#[test] | ||
fn test_struct_with_many_fields() { | ||
let mfs = ManyFieldStruct::new(400, true); | ||
assert_eq!(ManyFieldStruct { value1: 400, value2: true }, mfs); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use derive_ctor::ctor; | ||
|
||
#[derive(ctor, Debug, PartialEq)] | ||
struct MixedStruct { | ||
provided1: i16, | ||
provided2: bool, | ||
#[ctor(impl)] | ||
provided3: String, | ||
#[ctor(expr("Foo"))] | ||
generated1: &'static str, | ||
#[ctor(default)] | ||
generated2: u32 | ||
} | ||
|
||
#[test] | ||
fn test_struct_with_multiple_generated_fields() { | ||
let multi = MixedStruct::new(41, false, "Test"); | ||
assert_eq!(MixedStruct { provided1: 41, provided2: false, provided3: String::from("Test"), generated1: "Foo", generated2: Default::default() }, multi) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use derive_ctor::ctor; | ||
|
||
#[derive(ctor, Debug, PartialEq)] | ||
struct StructDefault { | ||
provided: String, | ||
#[ctor(default)] | ||
generated: u32 | ||
} | ||
|
||
#[derive(ctor, Debug, PartialEq)] | ||
struct StructManyDefault { | ||
provided: String, | ||
#[ctor(default)] | ||
generated1: u32, | ||
#[ctor(default)] | ||
generated2: String | ||
} | ||
|
||
#[test] | ||
fn test_struct_with_default_field() { | ||
let test = StructDefault::new(String::from("ABC")); | ||
assert_eq!(StructDefault { provided: String::from("ABC"), generated: Default::default() }, test); | ||
} | ||
|
||
#[test] | ||
fn test_struct_with_multiple_default_fields() { | ||
let test = StructManyDefault::new(String::from("ABC")); | ||
assert_eq!(StructManyDefault { provided: String::from("ABC"), generated1: Default::default(), generated2: Default::default() }, test); | ||
} |
Oops, something went wrong.