-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add testcases for directives and add comments for clarity
- Loading branch information
Showing
1 changed file
with
34 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,15 +1,45 @@ | ||
package i | ||
|
||
func excludedConsumer(e TestExcluded) string { | ||
return e.A | ||
} | ||
|
||
func shouldNotFailOnIgnoreDirective() (Test, error) { | ||
// directive on previous line | ||
//exhaustruct:ignore | ||
_ = Test2{} | ||
|
||
// directive at the end of the line | ||
_ = Test{} //exhaustruct:ignore | ||
|
||
// some style weirdness | ||
_ = | ||
//exhaustruct:ignore | ||
Test3{ | ||
B: 0, | ||
} | ||
|
||
// directive after the literal | ||
_ = Test{ | ||
B: 0, | ||
} //exhaustruct:ignore | ||
|
||
//exhaustruct:ignore | ||
return Test{}, nil | ||
} | ||
|
||
func shouldNotFailOnIgnoreDirectivePlacedOnEOL() (Test, error) { | ||
return Test{}, nil //exhaustruct:ignore | ||
} | ||
func shouldFailOnExcludedButEnforced() { | ||
// directive on previous line associated with different ast leaf | ||
//exhaustruct:enforce | ||
_ = excludedConsumer(TestExcluded{B: 0}) // want "i.TestExcluded is missing field A" | ||
|
||
func shouldNotPassExcludedButEnforced() { | ||
// initially excluded, but enforced | ||
//exhaustruct:enforce | ||
_ = TestExcluded{} // want "i.TestExcluded is missing fields A, B" | ||
} | ||
|
||
func shouldFailOnMisappliedDirectives() { | ||
// wrong directive name | ||
//exhaustive:enforce | ||
_ = TestExcluded{B: 0} | ||
} |