blob: df62f5c6bc1f8362edd9e9a2ef045cb88fd8ce36 [file] [log] [blame]
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.9.8" xml:lang="en-US">
<compounddef id="expression__test_8cc" kind="file" language="C++">
<compoundname>expression_test.cc</compoundname>
<includes refid="expression_8h" local="yes">iceberg/expression/expression.h</includes>
<includes local="no">memory</includes>
<includes local="no">gtest/gtest.h</includes>
<includes refid="matchers_8h" local="yes">iceberg/test/matchers.h</includes>
<incdepgraph>
<node id="13">
<label>iceberg/exception.h</label>
<link refid="exception_8h"/>
<childnode refid="14" relation="include">
</childnode>
<childnode refid="5" relation="include">
</childnode>
</node>
<node id="2">
<label>iceberg/expression/expression.h</label>
<link refid="expression_8h"/>
<childnode refid="3" relation="include">
</childnode>
<childnode refid="4" relation="include">
</childnode>
<childnode refid="5" relation="include">
</childnode>
<childnode refid="6" relation="include">
</childnode>
<childnode refid="9" relation="include">
</childnode>
<childnode refid="10" relation="include">
</childnode>
<childnode refid="11" relation="include">
</childnode>
</node>
<node id="5">
<label>iceberg/iceberg_export.h</label>
<link refid="iceberg__export_8h_source"/>
</node>
<node id="6">
<label>iceberg/result.h</label>
<link refid="result_8h_source"/>
<childnode refid="7" relation="include">
</childnode>
<childnode refid="8" relation="include">
</childnode>
<childnode refid="4" relation="include">
</childnode>
<childnode refid="5" relation="include">
</childnode>
</node>
<node id="1">
<label>iceberg/test/expression_test.cc</label>
<link refid="expression__test_8cc"/>
<childnode refid="2" relation="include">
</childnode>
<childnode refid="3" relation="include">
</childnode>
<childnode refid="15" relation="include">
</childnode>
<childnode refid="16" relation="include">
</childnode>
</node>
<node id="16">
<label>iceberg/test/matchers.h</label>
<link refid="matchers_8h_source"/>
<childnode refid="17" relation="include">
</childnode>
<childnode refid="15" relation="include">
</childnode>
<childnode refid="6" relation="include">
</childnode>
<childnode refid="11" relation="include">
</childnode>
</node>
<node id="9">
<label>iceberg/type_fwd.h</label>
<link refid="type__fwd_8h"/>
</node>
<node id="10">
<label>iceberg/util/formattable.h</label>
<link refid="formattable_8h"/>
<childnode refid="4" relation="include">
</childnode>
<childnode refid="5" relation="include">
</childnode>
</node>
<node id="11">
<label>iceberg/util/macros.h</label>
<link refid="macros_8h_source"/>
<childnode refid="12" relation="include">
</childnode>
<childnode refid="13" relation="include">
</childnode>
<childnode refid="6" relation="include">
</childnode>
</node>
<node id="12">
<label>cassert</label>
</node>
<node id="7">
<label>expected</label>
</node>
<node id="8">
<label>format</label>
</node>
<node id="17">
<label>gmock/gmock.h</label>
</node>
<node id="15">
<label>gtest/gtest.h</label>
</node>
<node id="3">
<label>memory</label>
</node>
<node id="14">
<label>stdexcept</label>
</node>
<node id="4">
<label>string</label>
</node>
</incdepgraph>
<innernamespace refid="namespaceiceberg">iceberg</innernamespace>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<programlisting>
<codeline lineno="1"><highlight class="comment">/*</highlight></codeline>
<codeline lineno="2"><highlight class="comment"><sp/>*<sp/>Licensed<sp/>to<sp/>the<sp/>Apache<sp/>Software<sp/>Foundation<sp/>(ASF)<sp/>under<sp/>one</highlight></codeline>
<codeline lineno="3"><highlight class="comment"><sp/>*<sp/>or<sp/>more<sp/>contributor<sp/>license<sp/>agreements.<sp/><sp/>See<sp/>the<sp/>NOTICE<sp/>file</highlight></codeline>
<codeline lineno="4"><highlight class="comment"><sp/>*<sp/>distributed<sp/>with<sp/>this<sp/>work<sp/>for<sp/>additional<sp/>information</highlight></codeline>
<codeline lineno="5"><highlight class="comment"><sp/>*<sp/>regarding<sp/>copyright<sp/>ownership.<sp/><sp/>The<sp/>ASF<sp/>licenses<sp/>this<sp/>file</highlight></codeline>
<codeline lineno="6"><highlight class="comment"><sp/>*<sp/>to<sp/>you<sp/>under<sp/>the<sp/>Apache<sp/>License,<sp/>Version<sp/>2.0<sp/>(the</highlight></codeline>
<codeline lineno="7"><highlight class="comment"><sp/>*<sp/>&quot;License&quot;);<sp/>you<sp/>may<sp/>not<sp/>use<sp/>this<sp/>file<sp/>except<sp/>in<sp/>compliance</highlight></codeline>
<codeline lineno="8"><highlight class="comment"><sp/>*<sp/>with<sp/>the<sp/>License.<sp/><sp/>You<sp/>may<sp/>obtain<sp/>a<sp/>copy<sp/>of<sp/>the<sp/>License<sp/>at</highlight></codeline>
<codeline lineno="9"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="10"><highlight class="comment"><sp/>*<sp/><sp/><sp/>http://www.apache.org/licenses/LICENSE-2.0</highlight></codeline>
<codeline lineno="11"><highlight class="comment"><sp/>*</highlight></codeline>
<codeline lineno="12"><highlight class="comment"><sp/>*<sp/>Unless<sp/>required<sp/>by<sp/>applicable<sp/>law<sp/>or<sp/>agreed<sp/>to<sp/>in<sp/>writing,</highlight></codeline>
<codeline lineno="13"><highlight class="comment"><sp/>*<sp/>software<sp/>distributed<sp/>under<sp/>the<sp/>License<sp/>is<sp/>distributed<sp/>on<sp/>an</highlight></codeline>
<codeline lineno="14"><highlight class="comment"><sp/>*<sp/>&quot;AS<sp/>IS&quot;<sp/>BASIS,<sp/>WITHOUT<sp/>WARRANTIES<sp/>OR<sp/>CONDITIONS<sp/>OF<sp/>ANY</highlight></codeline>
<codeline lineno="15"><highlight class="comment"><sp/>*<sp/>KIND,<sp/>either<sp/>express<sp/>or<sp/>implied.<sp/><sp/>See<sp/>the<sp/>License<sp/>for<sp/>the</highlight></codeline>
<codeline lineno="16"><highlight class="comment"><sp/>*<sp/>specific<sp/>language<sp/>governing<sp/>permissions<sp/>and<sp/>limitations</highlight></codeline>
<codeline lineno="17"><highlight class="comment"><sp/>*<sp/>under<sp/>the<sp/>License.</highlight></codeline>
<codeline lineno="18"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="19"><highlight class="normal"></highlight></codeline>
<codeline lineno="20"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;<ref refid="expression_8h" kindref="compound">iceberg/expression/expression.h</ref>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="21"><highlight class="normal"></highlight></codeline>
<codeline lineno="22"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;memory&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="23"><highlight class="normal"></highlight></codeline>
<codeline lineno="24"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;gtest/gtest.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="25"><highlight class="normal"></highlight></codeline>
<codeline lineno="26"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;iceberg/test/matchers.h&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="27"><highlight class="normal"></highlight></codeline>
<codeline lineno="28"><highlight class="normal"></highlight><highlight class="keyword">namespace<sp/></highlight><highlight class="normal">iceberg<sp/>{</highlight></codeline>
<codeline lineno="29"><highlight class="normal"></highlight></codeline>
<codeline lineno="30"><highlight class="normal">TEST(TrueFalseTest,<sp/>Basic)<sp/>{</highlight></codeline>
<codeline lineno="31"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>negation<sp/>of<sp/>False<sp/>returns<sp/>True</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="32"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>false_instance<sp/>=<sp/><ref refid="classiceberg_1_1False_1a2e7ef9efa2bfb8a83a66a06cafd54880" kindref="member">False::Instance</ref>();</highlight></codeline>
<codeline lineno="33"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negated_result<sp/>=<sp/>false_instance-&gt;Negate();</highlight></codeline>
<codeline lineno="34"><highlight class="normal"><sp/><sp/>ASSERT_THAT(negated_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="35"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negated<sp/>=<sp/>negated_result.value();</highlight></codeline>
<codeline lineno="36"><highlight class="normal"></highlight></codeline>
<codeline lineno="37"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Check<sp/>that<sp/>negated<sp/>expression<sp/>is<sp/>True</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="38"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated-&gt;op(),<sp/>Expression::Operation::kTrue);</highlight></codeline>
<codeline lineno="39"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated-&gt;ToString(),<sp/></highlight><highlight class="stringliteral">&quot;true&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="40"><highlight class="normal"></highlight></codeline>
<codeline lineno="41"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>negation<sp/>of<sp/>True<sp/>returns<sp/>false</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="42"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_instance<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="43"><highlight class="normal"><sp/><sp/>negated_result<sp/>=<sp/>true_instance-&gt;Negate();</highlight></codeline>
<codeline lineno="44"><highlight class="normal"><sp/><sp/>ASSERT_THAT(negated_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="45"><highlight class="normal"><sp/><sp/>negated<sp/>=<sp/>negated_result.value();</highlight></codeline>
<codeline lineno="46"><highlight class="normal"></highlight></codeline>
<codeline lineno="47"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Check<sp/>that<sp/>negated<sp/>expression<sp/>is<sp/>False</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated-&gt;op(),<sp/>Expression::Operation::kFalse);</highlight></codeline>
<codeline lineno="49"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated-&gt;ToString(),<sp/></highlight><highlight class="stringliteral">&quot;false&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="50"><highlight class="normal">}</highlight></codeline>
<codeline lineno="51"><highlight class="normal"></highlight></codeline>
<codeline lineno="52"><highlight class="normal">TEST(ANDTest,<sp/>Basic)<sp/>{</highlight></codeline>
<codeline lineno="53"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>two<sp/>True<sp/>expressions</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="54"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr1<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="55"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr2<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="56"><highlight class="normal"></highlight></codeline>
<codeline lineno="57"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>an<sp/>AND<sp/>expression</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="58"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1And_1a3091da0e23f4e1673f6b14bd778767fd" kindref="member">And::Make</ref>(true_expr1,<sp/>true_expr2);</highlight></codeline>
<codeline lineno="59"><highlight class="normal"><sp/><sp/>ASSERT_THAT(and_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="60"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(and_expr_result.value()));</highlight></codeline>
<codeline lineno="61"><highlight class="normal"></highlight></codeline>
<codeline lineno="62"><highlight class="normal"><sp/><sp/>EXPECT_EQ(and_expr-&gt;op(),<sp/>Expression::Operation::kAnd);</highlight></codeline>
<codeline lineno="63"><highlight class="normal"><sp/><sp/>EXPECT_EQ(and_expr-&gt;ToString(),<sp/></highlight><highlight class="stringliteral">&quot;(true<sp/>and<sp/>true)&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="64"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal">&amp;<sp/>and_ref<sp/>=<sp/></highlight><highlight class="keyword">static_cast&lt;</highlight><highlight class="keyword">const<sp/></highlight><highlight class="normal">And&amp;</highlight><highlight class="keyword">&gt;</highlight><highlight class="normal">(*and_expr);</highlight></codeline>
<codeline lineno="65"><highlight class="normal"><sp/><sp/>EXPECT_EQ(and_ref.left()-&gt;op(),<sp/>Expression::Operation::kTrue);</highlight></codeline>
<codeline lineno="66"><highlight class="normal"><sp/><sp/>EXPECT_EQ(and_ref.right()-&gt;op(),<sp/>Expression::Operation::kTrue);</highlight></codeline>
<codeline lineno="67"><highlight class="normal">}</highlight></codeline>
<codeline lineno="68"><highlight class="normal"></highlight></codeline>
<codeline lineno="69"><highlight class="normal">TEST(ORTest,<sp/>Basic)<sp/>{</highlight></codeline>
<codeline lineno="70"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>True<sp/>and<sp/>False<sp/>expressions</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="71"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="72"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>false_expr<sp/>=<sp/><ref refid="classiceberg_1_1False_1a2e7ef9efa2bfb8a83a66a06cafd54880" kindref="member">False::Instance</ref>();</highlight></codeline>
<codeline lineno="73"><highlight class="normal"></highlight></codeline>
<codeline lineno="74"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>an<sp/>OR<sp/>expression</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="75"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1Or_1a6578d82aa5380e6dfaa1fb28667c52c9" kindref="member">Or::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="76"><highlight class="normal"><sp/><sp/>ASSERT_THAT(or_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="77"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(or_expr_result.value()));</highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight></codeline>
<codeline lineno="79"><highlight class="normal"><sp/><sp/>EXPECT_EQ(or_expr-&gt;op(),<sp/>Expression::Operation::kOr);</highlight></codeline>
<codeline lineno="80"><highlight class="normal"><sp/><sp/>EXPECT_EQ(or_expr-&gt;ToString(),<sp/></highlight><highlight class="stringliteral">&quot;(true<sp/>or<sp/>false)&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="81"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal">&amp;<sp/>or_ref<sp/>=<sp/></highlight><highlight class="keyword">static_cast&lt;</highlight><highlight class="keyword">const<sp/></highlight><highlight class="normal">Or&amp;</highlight><highlight class="keyword">&gt;</highlight><highlight class="normal">(*or_expr);</highlight></codeline>
<codeline lineno="82"><highlight class="normal"><sp/><sp/>EXPECT_EQ(or_ref.left()-&gt;op(),<sp/>Expression::Operation::kTrue);</highlight></codeline>
<codeline lineno="83"><highlight class="normal"><sp/><sp/>EXPECT_EQ(or_ref.right()-&gt;op(),<sp/>Expression::Operation::kFalse);</highlight></codeline>
<codeline lineno="84"><highlight class="normal">}</highlight></codeline>
<codeline lineno="85"><highlight class="normal"></highlight></codeline>
<codeline lineno="86"><highlight class="normal">TEST(ORTest,<sp/>Negation)<sp/>{</highlight></codeline>
<codeline lineno="87"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>De<sp/>Morgan&apos;s<sp/>law:<sp/>not(A<sp/>or<sp/>B)<sp/>=<sp/>(not<sp/>A)<sp/>and<sp/>(not<sp/>B)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="88"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="89"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>false_expr<sp/>=<sp/><ref refid="classiceberg_1_1False_1a2e7ef9efa2bfb8a83a66a06cafd54880" kindref="member">False::Instance</ref>();</highlight></codeline>
<codeline lineno="90"><highlight class="normal"></highlight></codeline>
<codeline lineno="91"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1Or_1a6578d82aa5380e6dfaa1fb28667c52c9" kindref="member">Or::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="92"><highlight class="normal"><sp/><sp/>ASSERT_THAT(or_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="93"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(or_expr_result.value()));</highlight></codeline>
<codeline lineno="94"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negated_or_result<sp/>=<sp/>or_expr-&gt;Negate();</highlight></codeline>
<codeline lineno="95"><highlight class="normal"><sp/><sp/>ASSERT_THAT(negated_or_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="96"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negated_or<sp/>=<sp/>negated_or_result.value();</highlight></codeline>
<codeline lineno="97"><highlight class="normal"></highlight></codeline>
<codeline lineno="98"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Should<sp/>become<sp/>AND<sp/>expression</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="99"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated_or-&gt;op(),<sp/>Expression::Operation::kAnd);</highlight></codeline>
<codeline lineno="100"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated_or-&gt;ToString(),<sp/></highlight><highlight class="stringliteral">&quot;(false<sp/>and<sp/>true)&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="101"><highlight class="normal">}</highlight></codeline>
<codeline lineno="102"><highlight class="normal"></highlight></codeline>
<codeline lineno="103"><highlight class="normal">TEST(ORTest,<sp/>Equals)<sp/>{</highlight></codeline>
<codeline lineno="104"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="105"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>false_expr<sp/>=<sp/><ref refid="classiceberg_1_1False_1a2e7ef9efa2bfb8a83a66a06cafd54880" kindref="member">False::Instance</ref>();</highlight></codeline>
<codeline lineno="106"><highlight class="normal"></highlight></codeline>
<codeline lineno="107"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>basic<sp/>equality</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="108"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr1_result<sp/>=<sp/><ref refid="classiceberg_1_1Or_1a6578d82aa5380e6dfaa1fb28667c52c9" kindref="member">Or::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="109"><highlight class="normal"><sp/><sp/>ASSERT_THAT(or_expr1_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="110"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr1<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(or_expr1_result.value()));</highlight></codeline>
<codeline lineno="111"><highlight class="normal"></highlight></codeline>
<codeline lineno="112"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr2_result<sp/>=<sp/><ref refid="classiceberg_1_1Or_1a6578d82aa5380e6dfaa1fb28667c52c9" kindref="member">Or::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="113"><highlight class="normal"><sp/><sp/>ASSERT_THAT(or_expr2_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="114"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr2<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(or_expr2_result.value()));</highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/>EXPECT_TRUE(or_expr1-&gt;Equals(*or_expr2));</highlight></codeline>
<codeline lineno="116"><highlight class="normal"></highlight></codeline>
<codeline lineno="117"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>commutativity:<sp/>(A<sp/>or<sp/>B)<sp/>equals<sp/>(B<sp/>or<sp/>A)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="118"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr3_result<sp/>=<sp/><ref refid="classiceberg_1_1Or_1a6578d82aa5380e6dfaa1fb28667c52c9" kindref="member">Or::Make</ref>(false_expr,<sp/>true_expr);</highlight></codeline>
<codeline lineno="119"><highlight class="normal"><sp/><sp/>ASSERT_THAT(or_expr3_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="120"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr3<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(or_expr3_result.value()));</highlight></codeline>
<codeline lineno="121"><highlight class="normal"><sp/><sp/>EXPECT_TRUE(or_expr1-&gt;Equals(*or_expr3));</highlight></codeline>
<codeline lineno="122"><highlight class="normal"></highlight></codeline>
<codeline lineno="123"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>inequality<sp/>with<sp/>different<sp/>expressions</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="124"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr4_result<sp/>=<sp/><ref refid="classiceberg_1_1Or_1a6578d82aa5380e6dfaa1fb28667c52c9" kindref="member">Or::Make</ref>(true_expr,<sp/>true_expr);</highlight></codeline>
<codeline lineno="125"><highlight class="normal"><sp/><sp/>ASSERT_THAT(or_expr4_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="126"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr4<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(or_expr4_result.value()));</highlight></codeline>
<codeline lineno="127"><highlight class="normal"><sp/><sp/>EXPECT_FALSE(or_expr1-&gt;Equals(*or_expr4));</highlight></codeline>
<codeline lineno="128"><highlight class="normal"></highlight></codeline>
<codeline lineno="129"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>inequality<sp/>with<sp/>different<sp/>operation<sp/>types</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="130"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1And_1a3091da0e23f4e1673f6b14bd778767fd" kindref="member">And::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="131"><highlight class="normal"><sp/><sp/>ASSERT_THAT(and_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="132"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(and_expr_result.value()));</highlight></codeline>
<codeline lineno="133"><highlight class="normal"><sp/><sp/>EXPECT_FALSE(or_expr1-&gt;Equals(*and_expr));</highlight></codeline>
<codeline lineno="134"><highlight class="normal">}</highlight></codeline>
<codeline lineno="135"><highlight class="normal"></highlight></codeline>
<codeline lineno="136"><highlight class="normal">TEST(ANDTest,<sp/>Negation)<sp/>{</highlight></codeline>
<codeline lineno="137"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>De<sp/>Morgan&apos;s<sp/>law:<sp/>not(A<sp/>and<sp/>B)<sp/>=<sp/>(not<sp/>A)<sp/>or<sp/>(not<sp/>B)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="138"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="139"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>false_expr<sp/>=<sp/><ref refid="classiceberg_1_1False_1a2e7ef9efa2bfb8a83a66a06cafd54880" kindref="member">False::Instance</ref>();</highlight></codeline>
<codeline lineno="140"><highlight class="normal"></highlight></codeline>
<codeline lineno="141"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1And_1a3091da0e23f4e1673f6b14bd778767fd" kindref="member">And::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="142"><highlight class="normal"><sp/><sp/>ASSERT_THAT(and_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="143"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(and_expr_result.value()));</highlight></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negated_and_result<sp/>=<sp/>and_expr-&gt;Negate();</highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/>ASSERT_THAT(negated_and_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="146"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negated_and<sp/>=<sp/>negated_and_result.value();</highlight></codeline>
<codeline lineno="147"><highlight class="normal"></highlight></codeline>
<codeline lineno="148"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Should<sp/>become<sp/>OR<sp/>expression</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="149"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated_and-&gt;op(),<sp/>Expression::Operation::kOr);</highlight></codeline>
<codeline lineno="150"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated_and-&gt;ToString(),<sp/></highlight><highlight class="stringliteral">&quot;(false<sp/>or<sp/>true)&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="151"><highlight class="normal">}</highlight></codeline>
<codeline lineno="152"><highlight class="normal"></highlight></codeline>
<codeline lineno="153"><highlight class="normal">TEST(ANDTest,<sp/>Equals)<sp/>{</highlight></codeline>
<codeline lineno="154"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="155"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>false_expr<sp/>=<sp/><ref refid="classiceberg_1_1False_1a2e7ef9efa2bfb8a83a66a06cafd54880" kindref="member">False::Instance</ref>();</highlight></codeline>
<codeline lineno="156"><highlight class="normal"></highlight></codeline>
<codeline lineno="157"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>basic<sp/>equality</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="158"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr1_result<sp/>=<sp/><ref refid="classiceberg_1_1And_1a3091da0e23f4e1673f6b14bd778767fd" kindref="member">And::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="159"><highlight class="normal"><sp/><sp/>ASSERT_THAT(and_expr1_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="160"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr1<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(and_expr1_result.value()));</highlight></codeline>
<codeline lineno="161"><highlight class="normal"></highlight></codeline>
<codeline lineno="162"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr2_result<sp/>=<sp/><ref refid="classiceberg_1_1And_1a3091da0e23f4e1673f6b14bd778767fd" kindref="member">And::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="163"><highlight class="normal"><sp/><sp/>ASSERT_THAT(and_expr2_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="164"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr2<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(and_expr2_result.value()));</highlight></codeline>
<codeline lineno="165"><highlight class="normal"><sp/><sp/>EXPECT_TRUE(and_expr1-&gt;Equals(*and_expr2));</highlight></codeline>
<codeline lineno="166"><highlight class="normal"></highlight></codeline>
<codeline lineno="167"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>commutativity:<sp/>(A<sp/>and<sp/>B)<sp/>equals<sp/>(B<sp/>and<sp/>A)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="168"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr3_result<sp/>=<sp/><ref refid="classiceberg_1_1And_1a3091da0e23f4e1673f6b14bd778767fd" kindref="member">And::Make</ref>(false_expr,<sp/>true_expr);</highlight></codeline>
<codeline lineno="169"><highlight class="normal"><sp/><sp/>ASSERT_THAT(and_expr3_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="170"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr3<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(and_expr3_result.value()));</highlight></codeline>
<codeline lineno="171"><highlight class="normal"><sp/><sp/>EXPECT_TRUE(and_expr1-&gt;Equals(*and_expr3));</highlight></codeline>
<codeline lineno="172"><highlight class="normal"></highlight></codeline>
<codeline lineno="173"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>inequality<sp/>with<sp/>different<sp/>expressions</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="174"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr4_result<sp/>=<sp/><ref refid="classiceberg_1_1And_1a3091da0e23f4e1673f6b14bd778767fd" kindref="member">And::Make</ref>(true_expr,<sp/>true_expr);</highlight></codeline>
<codeline lineno="175"><highlight class="normal"><sp/><sp/>ASSERT_THAT(and_expr4_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="176"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr4<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(and_expr4_result.value()));</highlight></codeline>
<codeline lineno="177"><highlight class="normal"><sp/><sp/>EXPECT_FALSE(and_expr1-&gt;Equals(*and_expr4));</highlight></codeline>
<codeline lineno="178"><highlight class="normal"></highlight></codeline>
<codeline lineno="179"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>inequality<sp/>with<sp/>different<sp/>operation<sp/>types</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="180"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1Or_1a6578d82aa5380e6dfaa1fb28667c52c9" kindref="member">Or::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/>ASSERT_THAT(or_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="182"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>or_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(or_expr_result.value()));</highlight></codeline>
<codeline lineno="183"><highlight class="normal"><sp/><sp/>EXPECT_FALSE(and_expr1-&gt;Equals(*or_expr));</highlight></codeline>
<codeline lineno="184"><highlight class="normal">}</highlight></codeline>
<codeline lineno="185"><highlight class="normal"></highlight></codeline>
<codeline lineno="186"><highlight class="normal">TEST(ExpressionTest,<sp/>BaseClassNegateErrorOut)<sp/>{</highlight></codeline>
<codeline lineno="187"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>a<sp/>mock<sp/>expression<sp/>that<sp/>doesn&apos;t<sp/>override<sp/>Negate()</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="188"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">class<sp/></highlight><highlight class="normal">MockExpression<sp/>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/>Expression<sp/>{</highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/><sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="190"><highlight class="normal"><sp/><sp/><sp/><sp/>Operation<sp/>op()</highlight><highlight class="keyword"><sp/>const<sp/>override<sp/></highlight><highlight class="normal">{<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>Operation::kTrue;<sp/>}</highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Deliberately<sp/>not<sp/>overriding<sp/>Negate()<sp/>to<sp/>test<sp/>base<sp/>class<sp/>behavior</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="192"><highlight class="normal"><sp/><sp/>};</highlight></codeline>
<codeline lineno="193"><highlight class="normal"></highlight></codeline>
<codeline lineno="194"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>mock_expr<sp/>=<sp/>std::make_shared&lt;MockExpression&gt;();</highlight></codeline>
<codeline lineno="195"><highlight class="normal"></highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Should<sp/>return<sp/>NotSupported<sp/>error<sp/>when<sp/>calling<sp/>Negate()<sp/>on<sp/>base<sp/>class</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="197"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negate_result<sp/>=<sp/>mock_expr-&gt;Negate();</highlight></codeline>
<codeline lineno="198"><highlight class="normal"><sp/><sp/>EXPECT_THAT(negate_result,<sp/>IsError(ErrorKind::kNotSupported));</highlight></codeline>
<codeline lineno="199"><highlight class="normal">}</highlight></codeline>
<codeline lineno="200"><highlight class="normal"></highlight></codeline>
<codeline lineno="201"><highlight class="normal">TEST(NotTest,<sp/>Basic)<sp/>{</highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1Not_1a3c20b41048d581a535fcad4b7f9735c5" kindref="member">Not::Make</ref>(true_expr);</highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/>ASSERT_THAT(not_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(not_expr_result.value()));</highlight></codeline>
<codeline lineno="206"><highlight class="normal"></highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/>EXPECT_EQ(not_expr-&gt;op(),<sp/>Expression::Operation::kNot);</highlight></codeline>
<codeline lineno="208"><highlight class="normal"><sp/><sp/>EXPECT_EQ(not_expr-&gt;ToString(),<sp/></highlight><highlight class="stringliteral">&quot;not(true)&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="209"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal">&amp;<sp/>not_ref<sp/>=<sp/></highlight><highlight class="keyword">static_cast&lt;</highlight><highlight class="keyword">const<sp/></highlight><highlight class="normal">Not&amp;</highlight><highlight class="keyword">&gt;</highlight><highlight class="normal">(*not_expr);</highlight></codeline>
<codeline lineno="210"><highlight class="normal"><sp/><sp/>EXPECT_EQ(not_ref.child()-&gt;op(),<sp/>Expression::Operation::kTrue);</highlight></codeline>
<codeline lineno="211"><highlight class="normal">}</highlight></codeline>
<codeline lineno="212"><highlight class="normal"></highlight></codeline>
<codeline lineno="213"><highlight class="normal">TEST(NotTest,<sp/>Negation)<sp/>{</highlight></codeline>
<codeline lineno="214"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>that<sp/>not(not(x))<sp/>=<sp/>x</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="215"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="216"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1Not_1a3c20b41048d581a535fcad4b7f9735c5" kindref="member">Not::Make</ref>(true_expr);</highlight></codeline>
<codeline lineno="217"><highlight class="normal"><sp/><sp/>ASSERT_THAT(not_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="218"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(not_expr_result.value()));</highlight></codeline>
<codeline lineno="219"><highlight class="normal"></highlight></codeline>
<codeline lineno="220"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negated_result<sp/>=<sp/>not_expr-&gt;Negate();</highlight></codeline>
<codeline lineno="221"><highlight class="normal"><sp/><sp/>ASSERT_THAT(negated_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="222"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>negated<sp/>=<sp/>negated_result.value();</highlight></codeline>
<codeline lineno="223"><highlight class="normal"></highlight></codeline>
<codeline lineno="224"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Should<sp/>return<sp/>the<sp/>original<sp/>true<sp/>expression</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="225"><highlight class="normal"><sp/><sp/>EXPECT_EQ(negated-&gt;op(),<sp/>Expression::Operation::kTrue);</highlight></codeline>
<codeline lineno="226"><highlight class="normal">}</highlight></codeline>
<codeline lineno="227"><highlight class="normal"></highlight></codeline>
<codeline lineno="228"><highlight class="normal">TEST(NotTest,<sp/>Equals)<sp/>{</highlight></codeline>
<codeline lineno="229"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>true_expr<sp/>=<sp/><ref refid="classiceberg_1_1True_1a613f11f21789dbb5bccfa79d7e55abea" kindref="member">True::Instance</ref>();</highlight></codeline>
<codeline lineno="230"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>false_expr<sp/>=<sp/><ref refid="classiceberg_1_1False_1a2e7ef9efa2bfb8a83a66a06cafd54880" kindref="member">False::Instance</ref>();</highlight></codeline>
<codeline lineno="231"><highlight class="normal"></highlight></codeline>
<codeline lineno="232"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>basic<sp/>equality</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="233"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr1_result<sp/>=<sp/><ref refid="classiceberg_1_1Not_1a3c20b41048d581a535fcad4b7f9735c5" kindref="member">Not::Make</ref>(true_expr);</highlight></codeline>
<codeline lineno="234"><highlight class="normal"><sp/><sp/>ASSERT_THAT(not_expr1_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="235"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr1<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(not_expr1_result.value()));</highlight></codeline>
<codeline lineno="236"><highlight class="normal"></highlight></codeline>
<codeline lineno="237"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr2_result<sp/>=<sp/><ref refid="classiceberg_1_1Not_1a3c20b41048d581a535fcad4b7f9735c5" kindref="member">Not::Make</ref>(true_expr);</highlight></codeline>
<codeline lineno="238"><highlight class="normal"><sp/><sp/>ASSERT_THAT(not_expr2_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="239"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr2<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(not_expr2_result.value()));</highlight></codeline>
<codeline lineno="240"><highlight class="normal"><sp/><sp/>EXPECT_TRUE(not_expr1-&gt;Equals(*not_expr2));</highlight></codeline>
<codeline lineno="241"><highlight class="normal"></highlight></codeline>
<codeline lineno="242"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>inequality<sp/>with<sp/>different<sp/>child<sp/>expressions</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="243"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr3_result<sp/>=<sp/><ref refid="classiceberg_1_1Not_1a3c20b41048d581a535fcad4b7f9735c5" kindref="member">Not::Make</ref>(false_expr);</highlight></codeline>
<codeline lineno="244"><highlight class="normal"><sp/><sp/>ASSERT_THAT(not_expr3_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>not_expr3<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(not_expr3_result.value()));</highlight></codeline>
<codeline lineno="246"><highlight class="normal"><sp/><sp/>EXPECT_FALSE(not_expr1-&gt;Equals(*not_expr3));</highlight></codeline>
<codeline lineno="247"><highlight class="normal"></highlight></codeline>
<codeline lineno="248"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>inequality<sp/>with<sp/>different<sp/>operation<sp/>types</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="249"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr_result<sp/>=<sp/><ref refid="classiceberg_1_1And_1a3091da0e23f4e1673f6b14bd778767fd" kindref="member">And::Make</ref>(true_expr,<sp/>false_expr);</highlight></codeline>
<codeline lineno="250"><highlight class="normal"><sp/><sp/>ASSERT_THAT(and_expr_result,<sp/>IsOk());</highlight></codeline>
<codeline lineno="251"><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>and_expr<sp/>=<sp/>std::shared_ptr&lt;Expression&gt;(std::move(and_expr_result.value()));</highlight></codeline>
<codeline lineno="252"><highlight class="normal"><sp/><sp/>EXPECT_FALSE(not_expr1-&gt;Equals(*and_expr));</highlight></codeline>
<codeline lineno="253"><highlight class="normal">}</highlight></codeline>
<codeline lineno="254"><highlight class="normal"></highlight></codeline>
<codeline lineno="255"><highlight class="normal">}<sp/><sp/></highlight><highlight class="comment">//<sp/>namespace<sp/>iceberg</highlight><highlight class="normal"></highlight></codeline>
</programlisting>
<location file="iceberg/test/expression_test.cc"/>
</compounddef>
</doxygen>