Skip to content

Commit

Permalink
Add "fixme" test and update negative test
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Feb 28, 2022
1 parent b828267 commit 3258692
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
13 changes: 3 additions & 10 deletions tests/kani/Intrinsics/Compiler/variant_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@
// kani-verify-fail

// Check that `variant_count` is not supported.
// Commented out code below can be enabled to ensure the implementation works as
// expected when support is added
// 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 {}
enum MyError {
Error1,
Error2,
}

fn main() {
let _ = mem::variant_count::<Void>();
// assert!(mem::variant_count::<Void>() == 0);
// assert!(mem::variant_count::<MyError>() == 2);
// assert!(mem::variant_count::<Option<u32>>() == 2);
// assert!(mem::variant_count::<Result<u32, MyError>>() == 2);
}
21 changes: 21 additions & 0 deletions tests/kani/Intrinsics/Compiler/variant_count_fixme.rs
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);
}

0 comments on commit 3258692

Please sign in to comment.