@@ -62,3 +62,45 @@ TEST_CASE("SMT core theory \"=\".", "[core][smt2_incremental]")
62
62
smt_bit_vector_constant_termt{2 , 8 }, smt_bool_literal_termt{true }));
63
63
}
64
64
}
65
+
66
+ TEST_CASE (" SMT core theory \" distinct\" ." , " [core][smt2_incremental]" )
67
+ {
68
+ SECTION (" Bool sorted term comparison" )
69
+ {
70
+ const smt_bool_literal_termt true_term{true };
71
+ const smt_bool_literal_termt false_term{false };
72
+ const auto bool_comparison =
73
+ smt_core_theoryt::distinct (true_term, false_term);
74
+ CHECK (bool_comparison.get_sort () == smt_bool_sortt{});
75
+ CHECK (
76
+ bool_comparison.function_identifier () ==
77
+ smt_identifier_termt{" distinct" , smt_bool_sortt{}});
78
+ REQUIRE (bool_comparison.arguments ().size () == 2 );
79
+ REQUIRE (bool_comparison.arguments ()[0 ].get () == true_term);
80
+ REQUIRE (bool_comparison.arguments ()[1 ].get () == false_term);
81
+ }
82
+
83
+ SECTION (" Bit vector sorted term comparison" )
84
+ {
85
+ const smt_bit_vector_constant_termt two{2 , 8 };
86
+ const smt_bit_vector_constant_termt three{3 , 8 };
87
+ const auto bit_vector_comparison = smt_core_theoryt::distinct (two, three);
88
+ CHECK (bit_vector_comparison.get_sort () == smt_bool_sortt{});
89
+ CHECK (
90
+ bit_vector_comparison.function_identifier () ==
91
+ smt_identifier_termt{" distinct" , smt_bool_sortt{}});
92
+ REQUIRE (bit_vector_comparison.arguments ().size () == 2 );
93
+ REQUIRE (bit_vector_comparison.arguments ()[0 ].get () == two);
94
+ REQUIRE (bit_vector_comparison.arguments ()[1 ].get () == three);
95
+ }
96
+
97
+ SECTION (" Mismatch sort invariant" )
98
+ {
99
+ cbmc_invariants_should_throwt invariants_throw;
100
+ CHECK_THROWS (smt_core_theoryt::distinct (
101
+ smt_bit_vector_constant_termt{2 , 8 },
102
+ smt_bit_vector_constant_termt{2 , 16 }));
103
+ CHECK_THROWS (smt_core_theoryt::distinct (
104
+ smt_bit_vector_constant_termt{2 , 8 }, smt_bool_literal_termt{true }));
105
+ }
106
+ }
0 commit comments