@@ -75,6 +75,47 @@ TEST(AddHoleAtPositionTest, BasicTest) {
7575 EXPECT_EQ (AddHoleAtPosition (8 , 0xFF ), 0b011111111 );
7676}
7777
78+ TEST (CanonicalizeFunctionTruthTableTest, AndGateWithXAndNotX) {
79+ LiteralIndex output = Literal (+1 ).Index ();
80+ std::vector<LiteralIndex> inputs{Literal (+2 ).Index (), Literal (-2 ).Index ()};
81+ int table = 0b1000 ;
82+ const int new_size =
83+ CanonicalizeFunctionTruthTable (output, absl::MakeSpan (inputs), table);
84+ CHECK_EQ (new_size, 0 ); // Fixed to zero.
85+ }
86+
87+ TEST (RemoveFixedInputTest, BasicTest1) {
88+ std::vector<LiteralIndex> inputs{Literal (+1 ).Index (), Literal (+2 ).Index (),
89+ Literal (+3 ).Index ()};
90+ int table = 0b01011010 ;
91+ const int new_size = RemoveFixedInput (1 , true , absl::MakeSpan (inputs), table);
92+ EXPECT_EQ (new_size, 2 );
93+ EXPECT_EQ (inputs[0 ], Literal (+1 ).Index ());
94+ EXPECT_EQ (inputs[1 ], Literal (+3 ).Index ());
95+ EXPECT_EQ (table, 0b0110 ) << std::bitset<4 >(table);
96+ }
97+
98+ TEST (RemoveFixedInputTest, BasicTest2) {
99+ std::vector<LiteralIndex> inputs{Literal (+1 ).Index (), Literal (+2 ).Index (),
100+ Literal (+3 ).Index ()};
101+ int table = 0b01011010 ;
102+ const int new_size =
103+ RemoveFixedInput (1 , false , absl::MakeSpan (inputs), table);
104+ EXPECT_EQ (new_size, 2 );
105+ EXPECT_EQ (inputs[0 ], Literal (+1 ).Index ());
106+ EXPECT_EQ (inputs[1 ], Literal (+3 ).Index ());
107+ EXPECT_EQ (table, 0b0110 ) << std::bitset<4 >(table);
108+ }
109+
110+ TEST (CanonicalizeFunctionTruthTableTest, AndGateWithXAndNotX2) {
111+ LiteralIndex output = Literal (+1 ).Index ();
112+ std::vector<LiteralIndex> inputs{Literal (-2 ).Index (), Literal (+2 ).Index ()};
113+ int table = 0b1000 ;
114+ const int new_size =
115+ CanonicalizeFunctionTruthTable (output, absl::MakeSpan (inputs), table);
116+ CHECK_EQ (new_size, 0 ); // Fixed to zero.
117+ }
118+
78119TEST (CanonicalizeFunctionTruthTableTest, RandomTest) {
79120 absl::BitGen random;
80121 const int num_vars = 8 ;
0 commit comments