-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Negative test case for
variant_count
(#854)
* Negative test case for `variant_count` * Add "fixme" test and update negative test Co-authored-by: Celina G. Val <celinval@amazon.com>
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-verify-fail | ||
|
||
// Check that `variant_count` is not supported. | ||
// This test can be replaced with `variant_count_fixme.rs` once the intrinsic is | ||
// supported and works as expected. | ||
|
||
#![feature(variant_count)] | ||
use std::mem; | ||
|
||
enum Void {} | ||
|
||
fn main() { | ||
let _ = mem::variant_count::<Void>(); | ||
} |
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,21 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Check that `variant_count` is supported and returns the expected result. | ||
|
||
#![feature(variant_count)] | ||
use std::mem; | ||
|
||
enum Void {} | ||
enum MyError { | ||
Error1, | ||
Error2, | ||
Error3, | ||
} | ||
|
||
fn main() { | ||
assert!(mem::variant_count::<Void>() == 0); | ||
assert!(mem::variant_count::<MyError>() == 3); | ||
assert!(mem::variant_count::<Option<u32>>() == 2); | ||
assert!(mem::variant_count::<Result<u32, MyError>>() == 2); | ||
} |