@@ -165,4 +165,45 @@ TEST(ExpressionTest, BaseClassNegateErrorOut) {
165165 auto negate_result = mock_expr->Negate ();
166166 EXPECT_THAT (negate_result, IsError (ErrorKind::kNotSupported ));
167167}
168+
169+ TEST (NotTest, Basic) {
170+ auto true_expr = True::Instance ();
171+ auto not_expr = std::make_shared<Not>(true_expr);
172+
173+ EXPECT_EQ (not_expr->op (), Expression::Operation::kNot );
174+ EXPECT_EQ (not_expr->ToString (), " not(true)" );
175+ EXPECT_EQ (not_expr->child ()->op (), Expression::Operation::kTrue );
176+ }
177+
178+ TEST (NotTest, Negation) {
179+ // Test that not(not(x)) = x
180+ auto true_expr = True::Instance ();
181+ auto not_expr = std::make_shared<Not>(true_expr);
182+
183+ auto negated_result = not_expr->Negate ();
184+ ASSERT_THAT (negated_result, IsOk ());
185+ auto negated = negated_result.value ();
186+
187+ // Should return the original true expression
188+ EXPECT_EQ (negated->op (), Expression::Operation::kTrue );
189+ }
190+
191+ TEST (NotTest, Equals) {
192+ auto true_expr = True::Instance ();
193+ auto false_expr = False::Instance ();
194+
195+ // Test basic equality
196+ auto not_expr1 = std::make_shared<Not>(true_expr);
197+ auto not_expr2 = std::make_shared<Not>(true_expr);
198+ EXPECT_TRUE (not_expr1->Equals (*not_expr2));
199+
200+ // Test inequality with different child expressions
201+ auto not_expr3 = std::make_shared<Not>(false_expr);
202+ EXPECT_FALSE (not_expr1->Equals (*not_expr3));
203+
204+ // Test inequality with different operation types
205+ auto and_expr = std::make_shared<And>(true_expr, false_expr);
206+ EXPECT_FALSE (not_expr1->Equals (*and_expr));
207+ }
208+
168209} // namespace iceberg
0 commit comments