Skip to content
Snippets Groups Projects
Select Git revision
  • 6a9f3e72ac873cacaa2ecfe5e980a9141f548239
  • develop default protected
  • feature/advection
  • feature/composite-scheme-other-fluxes
  • origin/stage/bouguettaia
  • save_clemence
  • feature/local-dt-fsi
  • feature/variational-hydro
  • feature/gmsh-reader
  • feature/reconstruction
  • feature/kinetic-schemes
  • feature/composite-scheme-sources
  • feature/serraille
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

test_BinaryExpressionProcessor_logic.cpp

Blame
  • test_BinaryExpressionProcessor_logic.cpp 5.74 KiB
    #include <catch2/catch_test_macros.hpp>
    #include <catch2/matchers/catch_matchers_all.hpp>
    
    #include <test_BinaryExpressionProcessor_utils.hpp>
    
    // clazy:excludeall=non-pod-global-static
    
    TEST_CASE("BinaryExpressionProcessor logic", "[language]")
    {
      SECTION("and")
      {
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = true and true;)", "b", true);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = false and true;)", "b", false);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = true and false;)", "b", false);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = false and false;)", "b", false);
    
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = (2<3) and ((3.2-1) != 2);)", "b", true);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = (1>4) and true;)", "b", false);
      }
    
      SECTION("or")
      {
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = true or true;)", "b", true);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = false or true;)", "b", true);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = true or false;)", "b", true);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = false or false;)", "b", false);
    
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = (2<3) and ((3.2-1) != 2);)", "b", true);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = (1>4) or true;)", "b", true);
      }
    
      SECTION("xor")
      {
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = true xor true;)", "b", false);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = false xor true;)", "b", true);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = true xor false;)", "b", true);
        CHECK_BINARY_EXPRESSION_RESULT(R"(let b:B, b = false xor false;)", "b", false);
      }
    
      SECTION("errors")
      {
        SECTION("bad implicit conversion")
        {
          SECTION("and")
          {
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types N and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(let n:N, n=1; n and true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and N)";
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(let n:N, n=2; false and n;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types Z and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(1 and true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and Z)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(false and 2;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types R and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(1.1 and true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and R)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(false and 2e-2;)", error_message);
            }
          }
    
          SECTION("or")
          {
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types N and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(let n:N, n=1; n or true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and N)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(let n:N, n=2; false or n;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types Z and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(1 or true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and Z)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(false or 2;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types R and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(1.1 or true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and R)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(false or 2e-2;)", error_message);
            }
          }
    
          SECTION("xor")
          {
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types N and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(let n:N, n=1; n xor true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and N)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(let n:N, n=2; false xor n;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types Z and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(1 xor true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and Z)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(false xor 2;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types R and B)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(1.1 xor true;)", error_message);
            }
            {
              const std::string error_message = R"(undefined binary operator
    note: incompatible operand types B and R)";
    
              CHECK_BINARY_EXPRESSION_THROWS_WITH(R"(false xor 2e-2;)", error_message);
            }
          }
        }
      }
    }