| 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 the basic usage of the division operation |
| 17 | func TestMathLogicDivSuite(t *testing.T) { |
| 18 | suite.Run(t, new(MathLogicDivSuite)) |
| 19 | } |
| 20 | |
| 21 | type MathLogicDivSuite struct { |
| 22 | suite.Suite |
| 23 | |
| 24 | session *r.Session |
| 25 | } |
| 26 | |
| 27 | func (suite *MathLogicDivSuite) SetupTest() { |
| 28 | suite.T().Log("Setting up MathLogicDivSuite") |
| 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("db_logic_div").Exec(suite.session) |
| 40 | err = r.DBCreate("db_logic_div").Exec(suite.session) |
| 41 | suite.Require().NoError(err) |
| 42 | err = r.DB("db_logic_div").Wait().Exec(suite.session) |
| 43 | suite.Require().NoError(err) |
| 44 | |
| 45 | } |
| 46 | |
| 47 | func (suite *MathLogicDivSuite) TearDownSuite() { |
| 48 | suite.T().Log("Tearing down MathLogicDivSuite") |
| 49 | |
| 50 | if suite.session != nil { |
| 51 | r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) |
| 52 | r.DBDrop("db_logic_div").Exec(suite.session) |
| 53 | |
| 54 | suite.session.Close() |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func (suite *MathLogicDivSuite) TestCases() { |
| 59 | suite.T().Log("Running MathLogicDivSuite: Tests for the basic usage of the division operation") |
| 60 | |
| 61 | { |
| 62 | // math_logic/div.yaml line #6 |
| 63 | /* 2 */ |
| 64 | var expected_ int = 2 |
| 65 | /* r.expr(4) / 2 */ |
| 66 | |
| 67 | suite.T().Log("About to run line #6: r.Expr(4).Div(2)") |
| 68 | |
| 69 | runAndAssert(suite.Suite, expected_, r.Expr(4).Div(2), suite.session, r.RunOpts{ |
| 70 | GeometryFormat: "raw", |
| 71 | GroupFormat: "map", |
| 72 | }) |
| 73 | suite.T().Log("Finished running line #6") |
| 74 | } |
| 75 | |
| 76 | { |
| 77 | // math_logic/div.yaml line #7 |
| 78 | /* 2 */ |
| 79 | var expected_ int = 2 |
| 80 | /* 4 / r.expr(2) */ |
| 81 | |
| 82 | suite.T().Log("About to run line #7: r.Div(4, r.Expr(2))") |
| 83 | |
| 84 | runAndAssert(suite.Suite, expected_, r.Div(4, r.Expr(2)), suite.session, r.RunOpts{ |
| 85 | GeometryFormat: "raw", |
| 86 | GroupFormat: "map", |
| 87 | }) |
| 88 | suite.T().Log("Finished running line #7") |
| 89 | } |
| 90 | |
| 91 | { |
| 92 | // math_logic/div.yaml line #8 |
| 93 | /* 2 */ |
| 94 | var expected_ int = 2 |
| 95 | /* r.expr(4).div(2) */ |
| 96 | |
| 97 | suite.T().Log("About to run line #8: r.Expr(4).Div(2)") |
| 98 | |
| 99 | runAndAssert(suite.Suite, expected_, r.Expr(4).Div(2), suite.session, r.RunOpts{ |
| 100 | GeometryFormat: "raw", |
| 101 | GroupFormat: "map", |
| 102 | }) |
| 103 | suite.T().Log("Finished running line #8") |
| 104 | } |
| 105 | |
| 106 | { |
| 107 | // math_logic/div.yaml line #15 |
| 108 | /* 0.5 */ |
| 109 | var expected_ float64 = 0.5 |
| 110 | /* r.expr(-1) / -2 */ |
| 111 | |
| 112 | suite.T().Log("About to run line #15: r.Expr(-1).Div(-2)") |
| 113 | |
| 114 | runAndAssert(suite.Suite, expected_, r.Expr(-1).Div(-2), suite.session, r.RunOpts{ |
| 115 | GeometryFormat: "raw", |
| 116 | GroupFormat: "map", |
| 117 | }) |
| 118 | suite.T().Log("Finished running line #15") |
| 119 | } |
| 120 | |
| 121 | { |
| 122 | // math_logic/div.yaml line #20 |
| 123 | /* 4.9 / 0.7 */ |
| 124 | var expected_ float64 = 4.9 / 0.7 |
| 125 | /* r.expr(4.9) / 0.7 */ |
| 126 | |
| 127 | suite.T().Log("About to run line #20: r.Expr(4.9).Div(0.7)") |
| 128 | |
| 129 | runAndAssert(suite.Suite, expected_, r.Expr(4.9).Div(0.7), suite.session, r.RunOpts{ |
| 130 | GeometryFormat: "raw", |
| 131 | GroupFormat: "map", |
| 132 | }) |
| 133 | suite.T().Log("Finished running line #20") |
| 134 | } |
| 135 | |
| 136 | { |
| 137 | // math_logic/div.yaml line #25 |
| 138 | /* 1.0/120 */ |
| 139 | var expected_ float64 = 1.0 / 120 |
| 140 | /* r.expr(1).div(2,3,4,5) */ |
| 141 | |
| 142 | suite.T().Log("About to run line #25: r.Expr(1).Div(2, 3, 4, 5)") |
| 143 | |
| 144 | runAndAssert(suite.Suite, expected_, r.Expr(1).Div(2, 3, 4, 5), suite.session, r.RunOpts{ |
| 145 | GeometryFormat: "raw", |
| 146 | GroupFormat: "map", |
| 147 | }) |
| 148 | suite.T().Log("Finished running line #25") |
| 149 | } |
| 150 | |
| 151 | { |
| 152 | // math_logic/div.yaml line #37 |
| 153 | /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ |
| 154 | var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") |
| 155 | /* r.expr(1) / 0 */ |
| 156 | |
| 157 | suite.T().Log("About to run line #37: r.Expr(1).Div(0)") |
| 158 | |
| 159 | runAndAssert(suite.Suite, expected_, r.Expr(1).Div(0), suite.session, r.RunOpts{ |
| 160 | GeometryFormat: "raw", |
| 161 | GroupFormat: "map", |
| 162 | }) |
| 163 | suite.T().Log("Finished running line #37") |
| 164 | } |
| 165 | |
| 166 | { |
| 167 | // math_logic/div.yaml line #38 |
| 168 | /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ |
| 169 | var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") |
| 170 | /* r.expr(2.0) / 0 */ |
| 171 | |
| 172 | suite.T().Log("About to run line #38: r.Expr(2.0).Div(0)") |
| 173 | |
| 174 | runAndAssert(suite.Suite, expected_, r.Expr(2.0).Div(0), suite.session, r.RunOpts{ |
| 175 | GeometryFormat: "raw", |
| 176 | GroupFormat: "map", |
| 177 | }) |
| 178 | suite.T().Log("Finished running line #38") |
| 179 | } |
| 180 | |
| 181 | { |
| 182 | // math_logic/div.yaml line #39 |
| 183 | /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ |
| 184 | var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") |
| 185 | /* r.expr(3) / 0.0 */ |
| 186 | |
| 187 | suite.T().Log("About to run line #39: r.Expr(3).Div(0.0)") |
| 188 | |
| 189 | runAndAssert(suite.Suite, expected_, r.Expr(3).Div(0.0), suite.session, r.RunOpts{ |
| 190 | GeometryFormat: "raw", |
| 191 | GroupFormat: "map", |
| 192 | }) |
| 193 | suite.T().Log("Finished running line #39") |
| 194 | } |
| 195 | |
| 196 | { |
| 197 | // math_logic/div.yaml line #40 |
| 198 | /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ |
| 199 | var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") |
| 200 | /* r.expr(4.0) / 0.0 */ |
| 201 | |
| 202 | suite.T().Log("About to run line #40: r.Expr(4.0).Div(0.0)") |
| 203 | |
| 204 | runAndAssert(suite.Suite, expected_, r.Expr(4.0).Div(0.0), suite.session, r.RunOpts{ |
| 205 | GeometryFormat: "raw", |
| 206 | GroupFormat: "map", |
| 207 | }) |
| 208 | suite.T().Log("Finished running line #40") |
| 209 | } |
| 210 | |
| 211 | { |
| 212 | // math_logic/div.yaml line #41 |
| 213 | /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ |
| 214 | var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") |
| 215 | /* r.expr(0) / 0 */ |
| 216 | |
| 217 | suite.T().Log("About to run line #41: r.Expr(0).Div(0)") |
| 218 | |
| 219 | runAndAssert(suite.Suite, expected_, r.Expr(0).Div(0), suite.session, r.RunOpts{ |
| 220 | GeometryFormat: "raw", |
| 221 | GroupFormat: "map", |
| 222 | }) |
| 223 | suite.T().Log("Finished running line #41") |
| 224 | } |
| 225 | |
| 226 | { |
| 227 | // math_logic/div.yaml line #42 |
| 228 | /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ |
| 229 | var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") |
| 230 | /* r.expr(0.0) / 0.0 */ |
| 231 | |
| 232 | suite.T().Log("About to run line #42: r.Expr(0.0).Div(0.0)") |
| 233 | |
| 234 | runAndAssert(suite.Suite, expected_, r.Expr(0.0).Div(0.0), suite.session, r.RunOpts{ |
| 235 | GeometryFormat: "raw", |
| 236 | GroupFormat: "map", |
| 237 | }) |
| 238 | suite.T().Log("Finished running line #42") |
| 239 | } |
| 240 | |
| 241 | { |
| 242 | // math_logic/div.yaml line #46 |
| 243 | /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [0]) */ |
| 244 | var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") |
| 245 | /* r.expr('a') / 0.8 */ |
| 246 | |
| 247 | suite.T().Log("About to run line #46: r.Expr('a').Div(0.8)") |
| 248 | |
| 249 | runAndAssert(suite.Suite, expected_, r.Expr("a").Div(0.8), suite.session, r.RunOpts{ |
| 250 | GeometryFormat: "raw", |
| 251 | GroupFormat: "map", |
| 252 | }) |
| 253 | suite.T().Log("Finished running line #46") |
| 254 | } |
| 255 | |
| 256 | { |
| 257 | // math_logic/div.yaml line #50 |
| 258 | /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [1]) */ |
| 259 | var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") |
| 260 | /* r.expr(1) / 'a' */ |
| 261 | |
| 262 | suite.T().Log("About to run line #50: r.Expr(1).Div('a')") |
| 263 | |
| 264 | runAndAssert(suite.Suite, expected_, r.Expr(1).Div("a"), suite.session, r.RunOpts{ |
| 265 | GeometryFormat: "raw", |
| 266 | GroupFormat: "map", |
| 267 | }) |
| 268 | suite.T().Log("Finished running line #50") |
| 269 | } |
| 270 | } |