gopkg.in/rethinkdb/rethinkdb-go.v6@v6.2.2/internal/integration/reql_tests/reql_math_logic_add_test.go (about)

     1  // Code generated by gen_tests.py and process_polyglot.py.
     2  // Do not edit this file directly.
     3  // The template for this file is located at:
     4  // ../template.go.tpl
     5  package reql_tests
     6  
     7  import (
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/stretchr/testify/suite"
    12  	r "gopkg.in/rethinkdb/rethinkdb-go.v6"
    13  	"gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare"
    14  )
    15  
    16  // Tests for basic usage of the add operation
    17  func TestMathLogicAddSuite(t *testing.T) {
    18  	suite.Run(t, new(MathLogicAddSuite))
    19  }
    20  
    21  type MathLogicAddSuite struct {
    22  	suite.Suite
    23  
    24  	session *r.Session
    25  }
    26  
    27  func (suite *MathLogicAddSuite) SetupTest() {
    28  	suite.T().Log("Setting up MathLogicAddSuite")
    29  	// Use imports to prevent errors
    30  	_ = time.Time{}
    31  	_ = compare.AnythingIsFine
    32  
    33  	session, err := r.Connect(r.ConnectOpts{
    34  		Address: url,
    35  	})
    36  	suite.Require().NoError(err, "Error returned when connecting to server")
    37  	suite.session = session
    38  
    39  	r.DBDrop("test").Exec(suite.session)
    40  	err = r.DBCreate("test").Exec(suite.session)
    41  	suite.Require().NoError(err)
    42  	err = r.DB("test").Wait().Exec(suite.session)
    43  	suite.Require().NoError(err)
    44  
    45  }
    46  
    47  func (suite *MathLogicAddSuite) TearDownSuite() {
    48  	suite.T().Log("Tearing down MathLogicAddSuite")
    49  
    50  	if suite.session != nil {
    51  		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
    52  		r.DBDrop("test").Exec(suite.session)
    53  
    54  		suite.session.Close()
    55  	}
    56  }
    57  
    58  func (suite *MathLogicAddSuite) TestCases() {
    59  	suite.T().Log("Running MathLogicAddSuite: Tests for basic usage of the add operation")
    60  
    61  	{
    62  		// math_logic/add.yaml line #3
    63  		/* 2 */
    64  		var expected_ int = 2
    65  		/* r.add(1, 1) */
    66  
    67  		suite.T().Log("About to run line #3: r.Add(1, 1)")
    68  
    69  		runAndAssert(suite.Suite, expected_, r.Add(1, 1), suite.session, r.RunOpts{
    70  			GeometryFormat: "raw",
    71  			GroupFormat:    "map",
    72  		})
    73  		suite.T().Log("Finished running line #3")
    74  	}
    75  
    76  	{
    77  		// math_logic/add.yaml line #8
    78  		/* 2 */
    79  		var expected_ int = 2
    80  		/* r.expr(1) + 1 */
    81  
    82  		suite.T().Log("About to run line #8: r.Expr(1).Add(1)")
    83  
    84  		runAndAssert(suite.Suite, expected_, r.Expr(1).Add(1), suite.session, r.RunOpts{
    85  			GeometryFormat: "raw",
    86  			GroupFormat:    "map",
    87  		})
    88  		suite.T().Log("Finished running line #8")
    89  	}
    90  
    91  	{
    92  		// math_logic/add.yaml line #9
    93  		/* 2 */
    94  		var expected_ int = 2
    95  		/* 1 + r.expr(1) */
    96  
    97  		suite.T().Log("About to run line #9: r.Add(1, r.Expr(1))")
    98  
    99  		runAndAssert(suite.Suite, expected_, r.Add(1, r.Expr(1)), suite.session, r.RunOpts{
   100  			GeometryFormat: "raw",
   101  			GroupFormat:    "map",
   102  		})
   103  		suite.T().Log("Finished running line #9")
   104  	}
   105  
   106  	{
   107  		// math_logic/add.yaml line #10
   108  		/* 2 */
   109  		var expected_ int = 2
   110  		/* r.expr(1).add(1) */
   111  
   112  		suite.T().Log("About to run line #10: r.Expr(1).Add(1)")
   113  
   114  		runAndAssert(suite.Suite, expected_, r.Expr(1).Add(1), suite.session, r.RunOpts{
   115  			GeometryFormat: "raw",
   116  			GroupFormat:    "map",
   117  		})
   118  		suite.T().Log("Finished running line #10")
   119  	}
   120  
   121  	{
   122  		// math_logic/add.yaml line #16
   123  		/* 0 */
   124  		var expected_ int = 0
   125  		/* r.expr(-1) + 1 */
   126  
   127  		suite.T().Log("About to run line #16: r.Expr(-1).Add(1)")
   128  
   129  		runAndAssert(suite.Suite, expected_, r.Expr(-1).Add(1), suite.session, r.RunOpts{
   130  			GeometryFormat: "raw",
   131  			GroupFormat:    "map",
   132  		})
   133  		suite.T().Log("Finished running line #16")
   134  	}
   135  
   136  	{
   137  		// math_logic/add.yaml line #21
   138  		/* 10.25 */
   139  		var expected_ float64 = 10.25
   140  		/* r.expr(1.75) + 8.5 */
   141  
   142  		suite.T().Log("About to run line #21: r.Expr(1.75).Add(8.5)")
   143  
   144  		runAndAssert(suite.Suite, expected_, r.Expr(1.75).Add(8.5), suite.session, r.RunOpts{
   145  			GeometryFormat: "raw",
   146  			GroupFormat:    "map",
   147  		})
   148  		suite.T().Log("Finished running line #21")
   149  	}
   150  
   151  	{
   152  		// math_logic/add.yaml line #27
   153  		/* '' */
   154  		var expected_ string = ""
   155  		/* r.expr('') + '' */
   156  
   157  		suite.T().Log("About to run line #27: r.Expr('').Add('')")
   158  
   159  		runAndAssert(suite.Suite, expected_, r.Expr("").Add(""), suite.session, r.RunOpts{
   160  			GeometryFormat: "raw",
   161  			GroupFormat:    "map",
   162  		})
   163  		suite.T().Log("Finished running line #27")
   164  	}
   165  
   166  	{
   167  		// math_logic/add.yaml line #32
   168  		/* 'abcdef' */
   169  		var expected_ string = "abcdef"
   170  		/* r.expr('abc') + 'def' */
   171  
   172  		suite.T().Log("About to run line #32: r.Expr('abc').Add('def')")
   173  
   174  		runAndAssert(suite.Suite, expected_, r.Expr("abc").Add("def"), suite.session, r.RunOpts{
   175  			GeometryFormat: "raw",
   176  			GroupFormat:    "map",
   177  		})
   178  		suite.T().Log("Finished running line #32")
   179  	}
   180  
   181  	{
   182  		// math_logic/add.yaml line #52
   183  		/* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", [1]) */
   184  		var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.")
   185  		/* r.expr(1) + 'a' */
   186  
   187  		suite.T().Log("About to run line #52: r.Expr(1).Add('a')")
   188  
   189  		runAndAssert(suite.Suite, expected_, r.Expr(1).Add("a"), suite.session, r.RunOpts{
   190  			GeometryFormat: "raw",
   191  			GroupFormat:    "map",
   192  		})
   193  		suite.T().Log("Finished running line #52")
   194  	}
   195  
   196  	{
   197  		// math_logic/add.yaml line #57
   198  		/* err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", [1]) */
   199  		var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.")
   200  		/* r.expr('a') + 1 */
   201  
   202  		suite.T().Log("About to run line #57: r.Expr('a').Add(1)")
   203  
   204  		runAndAssert(suite.Suite, expected_, r.Expr("a").Add(1), suite.session, r.RunOpts{
   205  			GeometryFormat: "raw",
   206  			GroupFormat:    "map",
   207  		})
   208  		suite.T().Log("Finished running line #57")
   209  	}
   210  
   211  	{
   212  		// math_logic/add.yaml line #62
   213  		/* err("ReqlQueryLogicError", "Expected type ARRAY but found NUMBER.", [1]) */
   214  		var expected_ Err = err("ReqlQueryLogicError", "Expected type ARRAY but found NUMBER.")
   215  		/* r.expr([]) + 1 */
   216  
   217  		suite.T().Log("About to run line #62: r.Expr([]interface{}{}).Add(1)")
   218  
   219  		runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Add(1), suite.session, r.RunOpts{
   220  			GeometryFormat: "raw",
   221  			GroupFormat:    "map",
   222  		})
   223  		suite.T().Log("Finished running line #62")
   224  	}
   225  }