github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/expressions/exp06_test.go (about)

     1  package expressions
     2  
     3  import "testing"
     4  
     5  func TestExpGreaterThan(t *testing.T) {
     6  	tests := []expressionTestT{
     7  		{
     8  			Expression: `"foobar" > "foobar"`,
     9  			Expected:   false,
    10  		},
    11  		{
    12  			Expression: `"foo" > "bar"`,
    13  			Expected:   true,
    14  		},
    15  		{
    16  			Expression: `"bar" > "foo"`,
    17  			Expected:   false,
    18  		},
    19  		///
    20  		{
    21  			Expression: `1 > 1`,
    22  			Expected:   false,
    23  		},
    24  		{
    25  			Expression: `1 > 2`,
    26  			Expected:   false,
    27  		},
    28  		{
    29  			Expression: `2 > 1`,
    30  			Expected:   true,
    31  		},
    32  		///
    33  		{
    34  			Expression: `1 > "1"`,
    35  			Error:      true,
    36  		},
    37  		{
    38  			Expression: `1 > "2"`,
    39  			Error:      true,
    40  		},
    41  		{
    42  			Expression: `2 > "1"`,
    43  			Error:      true,
    44  		},
    45  	}
    46  
    47  	testExpression(t, tests, true)
    48  }
    49  
    50  func TestExpGreaterThanOrEqual(t *testing.T) {
    51  	tests := []expressionTestT{
    52  		{
    53  			Expression: `"foobar" >= "foobar"`,
    54  			Expected:   true,
    55  		},
    56  		{
    57  			Expression: `"foo" >= "bar"`,
    58  			Expected:   true,
    59  		},
    60  		{
    61  			Expression: `"bar" >= "foo"`,
    62  			Expected:   false,
    63  		},
    64  		///
    65  		{
    66  			Expression: `1 >= 1`,
    67  			Expected:   true,
    68  		},
    69  		{
    70  			Expression: `1 >= 2`,
    71  			Expected:   false,
    72  		},
    73  		{
    74  			Expression: `2 >= 1`,
    75  			Expected:   true,
    76  		},
    77  		///
    78  		{
    79  			Expression: `1 >= "1"`,
    80  			Error:      true,
    81  		},
    82  		{
    83  			Expression: `1 >= "2"`,
    84  			Error:      true,
    85  		},
    86  		{
    87  			Expression: `2 >= "1"`,
    88  			Error:      true,
    89  		},
    90  	}
    91  
    92  	testExpression(t, tests, true)
    93  }
    94  
    95  func TestExpLessThan(t *testing.T) {
    96  	tests := []expressionTestT{
    97  		{
    98  			Expression: `"foobar" < "foobar"`,
    99  			Expected:   false,
   100  		},
   101  		{
   102  			Expression: `"foo" < "bar"`,
   103  			Expected:   false,
   104  		},
   105  		{
   106  			Expression: `"bar" < "foo"`,
   107  			Expected:   true,
   108  		},
   109  		///
   110  		{
   111  			Expression: `1 < 1`,
   112  			Expected:   false,
   113  		},
   114  		{
   115  			Expression: `1 < 2`,
   116  			Expected:   true,
   117  		},
   118  		{
   119  			Expression: `2 < 1`,
   120  			Expected:   false,
   121  		},
   122  		///
   123  		{
   124  			Expression: `1 < "1"`,
   125  			Error:      true,
   126  		},
   127  		{
   128  			Expression: `1 < "2"`,
   129  			Error:      true,
   130  		},
   131  		{
   132  			Expression: `2 < "1"`,
   133  			Error:      true,
   134  		},
   135  	}
   136  
   137  	testExpression(t, tests, true)
   138  }
   139  
   140  func TestExpLessThanOrEqual(t *testing.T) {
   141  	tests := []expressionTestT{
   142  		{
   143  			Expression: `"foobar" <= "foobar"`,
   144  			Expected:   true,
   145  		},
   146  		{
   147  			Expression: `"foo" <= "bar"`,
   148  			Expected:   false,
   149  		},
   150  		{
   151  			Expression: `"bar" <= "foo"`,
   152  			Expected:   true,
   153  		},
   154  		///
   155  		{
   156  			Expression: `1 <= 1`,
   157  			Expected:   true,
   158  		},
   159  		{
   160  			Expression: `1 <= 2`,
   161  			Expected:   true,
   162  		},
   163  		{
   164  			Expression: `2 <= 1`,
   165  			Expected:   false,
   166  		},
   167  		///
   168  		{
   169  			Expression: `1 <= "1"`,
   170  			Error:      true,
   171  		},
   172  		{
   173  			Expression: `1 <= "2"`,
   174  			Error:      true,
   175  		},
   176  		{
   177  			Expression: `2 <= "1"`,
   178  			Error:      true,
   179  		},
   180  	}
   181  
   182  	testExpression(t, tests, true)
   183  }