MySQL float expressions.

This commit is contained in:
go-jet 2019-07-30 15:04:36 +02:00
parent 6bf9c32c07
commit 163ecf4c42
13 changed files with 401 additions and 85 deletions

View file

@ -20,8 +20,8 @@ CREATE TABLE `all_types` (
`medium_int` MEDIUMINT NOT NULL,
`umedium_int` MEDIUMINT unsigned NOT NULL,
`int` INT NOT NULL,
`uint` INT unsigned NOT NULL,
`integer` INT NOT NULL,
`uinteger` INT unsigned NOT NULL,
`big_int` bigint(20) NOT NULL,
`ubig_int` bigint(20) unsigned NOT NULL,
@ -57,6 +57,9 @@ CREATE TABLE `all_types` (
`double` double NOT NULL,
`double_ptr` double,
`real` real NOT NULL,
`real_ptr` real,
-- bit values
`bit` bit(10) NOT NULL,
@ -110,8 +113,16 @@ CREATE TABLE `all_types` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
INSERT INTO `all_types` VALUES
(false, true, -3,3,-14,14,-150,150,-1600,1600,-17000,17000,-3,3,-14,14,-150,150,-1600,1600,-17000,17000,1.11,1.11,2.22,2.22,3.33,3.33,4.44,4.44,_binary '\0',_binary '\0','2008-07-04','2008-07-04','2011-12-18 13:17:17','2011-12-18 13:17:17','2007-12-31 23:00:01','2007-12-31 23:00:01',2004,2004,'char','char','varchar','varchar',_binary 'binary\0\0\0\0\0\0\0\0\0\0\0\0\0\0',_binary 'binary\0\0\0\0\0\0\0\0\0\0\0\0\0\0',_binary 'varbinary',_binary 'varbinary',_binary 'blob',_binary 'blob','text','text','value1','value1','s1','s2','{\"key1\": \"value1\", \"key2\": \"value2\"}','{\"key1\": \"value1\", \"key2\": \"value2\"}'),
(false, NULL, -3,3,-14,14,-150,150,-1600,1600,-17000,17000,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1.11,NULL,2.22,NULL,3.33,NULL,4.44,NULL,_binary '\0',NULL,'2008-07-04',NULL,'2011-12-18 13:17:17',NULL,'2007-12-31 23:00:01',NULL,2004,NULL,'char',NULL,'varchar',NULL,_binary 'binary\0\0\0\0\0\0\0\0\0\0\0\0\0\0',NULL,_binary 'varbinary',NULL,_binary 'blob',NULL,'text',NULL,'value1',NULL,'s1',NULL,'{\"key1\": \"value1\", \"key2\": \"value2\"}',NULL);
(false, true,
-3,3,-14,14,-150,150,-1600,1600,-17000,17000,
-3,3,-14,14,-150,150,-1600,1600,-17000,17000,
1.11,1.11,2.22,2.22,3.33,3.33,4.44,4.44,5.55,5.55,
_binary '\0',_binary '\0','2008-07-04','2008-07-04','2011-12-18 13:17:17','2011-12-18 13:17:17','2007-12-31 23:00:01','2007-12-31 23:00:01',2004,2004,'char','char','varchar','varchar',_binary 'binary\0\0\0\0\0\0\0\0\0\0\0\0\0\0',_binary 'binary\0\0\0\0\0\0\0\0\0\0\0\0\0\0',_binary 'varbinary',_binary 'varbinary',_binary 'blob',_binary 'blob','text','text','value1','value1','s1','s2','{\"key1\": \"value1\", \"key2\": \"value2\"}','{\"key1\": \"value1\", \"key2\": \"value2\"}'),
(false, NULL,
-3,3,-14,14,-150,150,-1600,1600,-17000,17000,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
1.11,NULL,2.22,NULL,3.33,NULL,4.44,NULL,5.55,NULL,
_binary '\0',NULL,'2008-07-04',NULL,'2011-12-18 13:17:17',NULL,'2007-12-31 23:00:01',NULL,2004,NULL,'char',NULL,'varchar',NULL,_binary 'binary\0\0\0\0\0\0\0\0\0\0\0\0\0\0',NULL,_binary 'varbinary',NULL,_binary 'blob',NULL,'text',NULL,'value1',NULL,'s1',NULL,'{\"key1\": \"value1\", \"key2\": \"value2\"}',NULL);

View file

@ -110,7 +110,7 @@ INSERT INTO test_sample.ALL_types(
xml_ptr, xml,
json_ptr, json, jsonb_ptr, jsonb,
integer_array_ptr, integer_array, text_array_ptr, text_array, jsonb_array, text_multi_dim_array_ptr, text_multi_dim_array)
VALUES (1, 1, 300, 300, 50000, 5000, 11.44, 11.44, 55.77, 55.77, 99.1, 99.1, 11111111.22, 11111111.22, DEFAULT, DEFAULT, DEFAULT,
VALUES (1, 1, 300, 300, 50000, 5000, 1.11, 1.11, 2.22, 2.22, 5.55, 5.55, 11111111.22, 11111111.22, DEFAULT, DEFAULT, DEFAULT,
-- 100000, 100000,
'ABBA', 'ABBA', 'JOHN', 'JOHN', 'Some text', 'Some text',
'bytea', 'bytea',
@ -124,7 +124,7 @@ VALUES (1, 1, 300, 300, 50000, 5000, 11.44, 11.44, 55.77, 55.77, 99.1, 99.1, 111
'{"a": 1, "b": 3}', '{"a": 1, "b": 3}', '{"a": 1, "b": 3}', '{"a": 1, "b": 3}',
'{1, 2, 3}', '{1, 2, 3}', '{"breakfast", "consulting"}', '{"breakfast", "consulting"}', ARRAY['{"a": 1, "b": 2}'::jsonb, '{"a":3, "b": 4}'::jsonb], '{{"meeting", "lunch"}, {"training", "presentation"}}', '{{"meeting", "lunch"}, {"training", "presentation"}}')
,
(NULL, 1, NULL, 300, NULL, 5000, NULL, 11.44, NULL, 55.77, NULL, 99.1, NULL, 11111111.22, DEFAULT, DEFAULT, DEFAULT,
(NULL, 1, NULL, 300, NULL, 5000, NULL, 1.11, NULL, 2.22, NULL, 5.55, NULL, 11111111.22, DEFAULT, DEFAULT, DEFAULT,
-- NULL, 100000,
NULL, 'ABBA', NULL, 'JOHN', NULL, 'Some text',
NULL, 'bytea',

View file

@ -4,6 +4,7 @@ import (
"github.com/go-jet/jet/internal/testutils"
"github.com/go-jet/jet/tests/.gentestdata/mysql/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/mysql/test_sample/table"
"github.com/go-jet/jet/tests/testdata/common"
. "github.com/go-jet/jet/mysql"
@ -93,11 +94,106 @@ FROM test_sample.all_types;
assert.NilError(t, err)
testutils.JsonPrint(dest)
testutils.AssertJSONFile(t, "./testdata/common/bool_operators.json", dest)
}
func TestFloatOperators(t *testing.T) {
query := AllTypes.SELECT(
AllTypes.Numeric.EQ(AllTypes.Numeric).AS("eq1"),
AllTypes.Decimal.EQ(Float(12.22)).AS("eq2"),
AllTypes.Real.EQ(Float(12.12)).AS("eq3"),
AllTypes.Numeric.IS_DISTINCT_FROM(AllTypes.Numeric).AS("distinct1"),
AllTypes.Decimal.IS_DISTINCT_FROM(Float(12)).AS("distinct2"),
AllTypes.Real.IS_DISTINCT_FROM(Float(12.12)).AS("distinct3"),
AllTypes.Numeric.IS_NOT_DISTINCT_FROM(AllTypes.Numeric).AS("not_distinct1"),
AllTypes.Decimal.IS_NOT_DISTINCT_FROM(Float(12)).AS("not_distinct2"),
AllTypes.Real.IS_NOT_DISTINCT_FROM(Float(12.12)).AS("not_distinct3"),
AllTypes.Numeric.LT(Float(124)).AS("lt1"),
AllTypes.Numeric.LT(Float(34.56)).AS("lt2"),
AllTypes.Numeric.GT(Float(124)).AS("gt1"),
AllTypes.Numeric.GT(Float(34.56)).AS("gt2"),
TRUNC(AllTypes.Decimal.ADD(AllTypes.Decimal), Int(2)).AS("add1"),
TRUNC(AllTypes.Decimal.ADD(Float(11.22)), Int(2)).AS("add2"),
TRUNC(AllTypes.Decimal.SUB(AllTypes.DecimalPtr), Int(2)).AS("sub1"),
TRUNC(AllTypes.Decimal.SUB(Float(11.22)), Int(2)).AS("sub2"),
TRUNC(AllTypes.Decimal.MUL(AllTypes.DecimalPtr), Int(2)).AS("mul1"),
TRUNC(AllTypes.Decimal.MUL(Float(11.22)), Int(2)).AS("mul2"),
TRUNC(AllTypes.Decimal.DIV(AllTypes.DecimalPtr), Int(2)).AS("div1"),
TRUNC(AllTypes.Decimal.DIV(Float(11.22)), Int(2)).AS("div2"),
TRUNC(AllTypes.Decimal.MOD(AllTypes.DecimalPtr), Int(2)).AS("mod1"),
TRUNC(AllTypes.Decimal.MOD(Float(11.22)), Int(2)).AS("mod2"),
TRUNC(AllTypes.Decimal.POW(AllTypes.DecimalPtr), Int(2)).AS("pow1"),
TRUNC(AllTypes.Decimal.POW(Float(2.1)), Int(2)).AS("pow2"),
TRUNC(ABSf(AllTypes.Decimal), Int(2)).AS("abs"),
TRUNC(POWER(AllTypes.Decimal, Float(2.1)), Int(2)).AS("power"),
TRUNC(SQRT(AllTypes.Decimal), Int(2)).AS("sqrt"),
TRUNC(CBRT(AllTypes.Decimal), Int(2)).AS("cbrt"),
CEIL(AllTypes.Real).AS("ceil"),
FLOOR(AllTypes.Real).AS("floor"),
ROUND(AllTypes.Decimal).AS("round1"),
ROUND(AllTypes.Decimal, Int(2)).AS("round2"),
SIGN(AllTypes.Real).AS("sign"),
TRUNC(AllTypes.Decimal, Int(1)).AS("trunc"),
).LIMIT(2)
queryStr, _, err := query.Sql()
assert.NilError(t, err)
assert.Equal(t, queryStr, `
SELECT (all_types.numeric = all_types.numeric) AS "eq1",
(all_types.decimal = ?) AS "eq2",
(all_types.real = ?) AS "eq3",
(NOT all_types.numeric <=> all_types.numeric) AS "distinct1",
(NOT all_types.decimal <=> ?) AS "distinct2",
(NOT all_types.real <=> ?) AS "distinct3",
(all_types.numeric <=> all_types.numeric) AS "not_distinct1",
(all_types.decimal <=> ?) AS "not_distinct2",
(all_types.real <=> ?) AS "not_distinct3",
(all_types.numeric < ?) AS "lt1",
(all_types.numeric < ?) AS "lt2",
(all_types.numeric > ?) AS "gt1",
(all_types.numeric > ?) AS "gt2",
TRUNCATE((all_types.decimal + all_types.decimal), ?) AS "add1",
TRUNCATE((all_types.decimal + ?), ?) AS "add2",
TRUNCATE((all_types.decimal - all_types.decimal_ptr), ?) AS "sub1",
TRUNCATE((all_types.decimal - ?), ?) AS "sub2",
TRUNCATE((all_types.decimal * all_types.decimal_ptr), ?) AS "mul1",
TRUNCATE((all_types.decimal * ?), ?) AS "mul2",
TRUNCATE((all_types.decimal / all_types.decimal_ptr), ?) AS "div1",
TRUNCATE((all_types.decimal / ?), ?) AS "div2",
TRUNCATE((all_types.decimal % all_types.decimal_ptr), ?) AS "mod1",
TRUNCATE((all_types.decimal % ?), ?) AS "mod2",
TRUNCATE(POWER(all_types.decimal, all_types.decimal_ptr), ?) AS "pow1",
TRUNCATE(POWER(all_types.decimal, ?), ?) AS "pow2",
TRUNCATE(ABS(all_types.decimal), ?) AS "abs",
TRUNCATE(POWER(all_types.decimal, ?), ?) AS "power",
TRUNCATE(SQRT(all_types.decimal), ?) AS "sqrt",
TRUNCATE(POWER(all_types.decimal, (? / ?)), ?) AS "cbrt",
CEIL(all_types.real) AS "ceil",
FLOOR(all_types.real) AS "floor",
ROUND(all_types.decimal) AS "round1",
ROUND(all_types.decimal, ?) AS "round2",
SIGN(all_types.real) AS "sign",
TRUNCATE(all_types.decimal, ?) AS "trunc"
FROM test_sample.all_types
LIMIT ?;
`)
var dest []struct {
common.FloatExpressionTestResult `alias:"."`
}
err = query.Query(db, &dest)
assert.NilError(t, err)
testutils.AssertJSONFile(t, "./testdata/common/float_operators.json", dest)
}
var allTypesJson = `
[
{
@ -109,8 +205,8 @@ var allTypesJson = `
"UsmallInt": 14,
"MediumInt": -150,
"UmediumInt": 150,
"Int": -1600,
"Uint": 1600,
"Integer": -1600,
"Uinteger": 1600,
"BigInt": -17000,
"UbigInt": 17000,
"TinyIntPtr": -3,
@ -131,6 +227,8 @@ var allTypesJson = `
"FloatPtr": 3.33,
"Double": 4.44,
"DoublePtr": 4.44,
"Real": 5.55,
"RealPtr": 5.55,
"Bit": "\u0000\u0003",
"BitPtr": "\u0000\u0003",
"Date": "2008-07-04T00:00:00Z",
@ -169,8 +267,8 @@ var allTypesJson = `
"UsmallInt": 14,
"MediumInt": -150,
"UmediumInt": 150,
"Int": -1600,
"Uint": 1600,
"Integer": -1600,
"Uinteger": 1600,
"BigInt": -17000,
"UbigInt": 17000,
"TinyIntPtr": null,
@ -191,6 +289,8 @@ var allTypesJson = `
"FloatPtr": null,
"Double": 4.44,
"DoublePtr": null,
"Real": 5.55,
"RealPtr": null,
"Bit": "\u0000\u0003",
"BitPtr": null,
"Date": "2008-07-04T00:00:00Z",

View file

@ -5,6 +5,7 @@ import (
"github.com/go-jet/jet/internal/testutils"
"github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/test_sample/table"
"github.com/go-jet/jet/tests/testdata/common"
"github.com/google/uuid"
"gotest.tools/assert"
"testing"
@ -245,52 +246,100 @@ LIMIT $5;
func TestFloatOperators(t *testing.T) {
query := AllTypes.SELECT(
AllTypes.Numeric.EQ(AllTypes.Numeric),
AllTypes.Decimal.EQ(Float(12)),
AllTypes.Real.EQ(Float(12.12)),
AllTypes.Numeric.IS_DISTINCT_FROM(AllTypes.Numeric),
AllTypes.Decimal.IS_DISTINCT_FROM(Float(12)),
AllTypes.Real.IS_DISTINCT_FROM(Float(12.12)),
AllTypes.Numeric.IS_NOT_DISTINCT_FROM(AllTypes.Numeric),
AllTypes.Decimal.IS_NOT_DISTINCT_FROM(Float(12)),
AllTypes.Real.IS_NOT_DISTINCT_FROM(Float(12.12)),
//AllTypes.Numeric.LT(AllTypes.Integer),
AllTypes.Numeric.LT(Float(124)),
AllTypes.Numeric.LT(Float(34.56)),
//AllTypes.Numeric.GT(AllTypes.Smallint),
AllTypes.Numeric.GT(Float(124)),
AllTypes.Numeric.GT(Float(34.56)),
AllTypes.Numeric.EQ(AllTypes.Numeric).AS("eq1"),
AllTypes.Decimal.EQ(Float(12.22)).AS("eq2"),
AllTypes.Real.EQ(Float(12.12)).AS("eq3"),
AllTypes.Numeric.IS_DISTINCT_FROM(AllTypes.Numeric).AS("distinct1"),
AllTypes.Decimal.IS_DISTINCT_FROM(Float(12)).AS("distinct2"),
AllTypes.Real.IS_DISTINCT_FROM(Float(12.12)).AS("distinct3"),
AllTypes.Numeric.IS_NOT_DISTINCT_FROM(AllTypes.Numeric).AS("not_distinct1"),
AllTypes.Decimal.IS_NOT_DISTINCT_FROM(Float(12)).AS("not_distinct2"),
AllTypes.Real.IS_NOT_DISTINCT_FROM(Float(12.12)).AS("not_distinct3"),
AllTypes.Numeric.LT(Float(124)).AS("lt1"),
AllTypes.Numeric.LT(Float(34.56)).AS("lt2"),
AllTypes.Numeric.GT(Float(124)).AS("gt1"),
AllTypes.Numeric.GT(Float(34.56)).AS("gt2"),
AllTypes.Real.ADD(AllTypes.RealPtr),
AllTypes.Real.ADD(Float(11.22)),
AllTypes.Real.SUB(AllTypes.RealPtr),
AllTypes.Real.SUB(Float(11.22)),
AllTypes.Real.MUL(AllTypes.RealPtr),
AllTypes.Real.MUL(Float(11.22)),
AllTypes.Real.DIV(AllTypes.RealPtr),
AllTypes.Real.DIV(Float(11.22)),
AllTypes.Decimal.MOD(AllTypes.Decimal),
AllTypes.Decimal.MOD(Float(11.22)),
AllTypes.Real.POW(AllTypes.RealPtr),
AllTypes.Real.POW(Float(11.22)),
TRUNC(AllTypes.Decimal.ADD(AllTypes.Decimal), Int(2)).AS("add1"),
TRUNC(AllTypes.Decimal.ADD(Float(11.22)), Int(2)).AS("add2"),
TRUNC(AllTypes.Decimal.SUB(AllTypes.DecimalPtr), Int(2)).AS("sub1"),
TRUNC(AllTypes.Decimal.SUB(Float(11.22)), Int(2)).AS("sub2"),
TRUNC(AllTypes.Decimal.MUL(AllTypes.DecimalPtr), Int(2)).AS("mul1"),
TRUNC(AllTypes.Decimal.MUL(Float(11.22)), Int(2)).AS("mul2"),
TRUNC(AllTypes.Decimal.DIV(AllTypes.DecimalPtr), Int(2)).AS("div1"),
TRUNC(AllTypes.Decimal.DIV(Float(11.22)), Int(2)).AS("div2"),
TRUNC(AllTypes.Decimal.MOD(AllTypes.DecimalPtr), Int(2)).AS("mod1"),
TRUNC(AllTypes.Decimal.MOD(Float(11.22)), Int(2)).AS("mod2"),
TRUNC(AllTypes.Decimal.POW(AllTypes.DecimalPtr), Int(2)).AS("pow1"),
TRUNC(AllTypes.Decimal.POW(Float(2.1)), Int(2)).AS("pow2"),
ABSf(AllTypes.Real),
SQRT(AllTypes.Real),
CBRT(AllTypes.Real),
CEIL(AllTypes.Real),
FLOOR(AllTypes.Real),
ROUND(AllTypes.Decimal),
ROUND(AllTypes.Decimal, AllTypes.Integer).AS("round"),
SIGN(AllTypes.Real),
TRUNC(AllTypes.Decimal),
TRUNC(AllTypes.Decimal, Int(1)),
)
TRUNC(ABSf(AllTypes.Decimal), Int(2)).AS("abs"),
TRUNC(POWER(AllTypes.Decimal, Float(2.1)), Int(2)).AS("power"),
TRUNC(SQRT(AllTypes.Decimal), Int(2)).AS("sqrt"),
TRUNC(CAST(CBRT(AllTypes.Decimal)).AS_DECIMAL(), Int(2)).AS("cbrt"),
//fmt.Println(query.DebugSql())
CEIL(AllTypes.Real).AS("ceil"),
FLOOR(AllTypes.Real).AS("floor"),
ROUND(AllTypes.Decimal).AS("round1"),
ROUND(AllTypes.Decimal, AllTypes.Integer).AS("round2"),
err := query.Query(db, &struct{}{})
SIGN(AllTypes.Real).AS("sign"),
TRUNC(AllTypes.Decimal, Int(1)).AS("trunc"),
).LIMIT(2)
queryStr, _, err := query.Sql()
assert.NilError(t, err)
assert.Equal(t, queryStr, `
SELECT (all_types.numeric = all_types.numeric) AS "eq1",
(all_types.decimal = $1) AS "eq2",
(all_types.real = $2) AS "eq3",
(all_types.numeric IS DISTINCT FROM all_types.numeric) AS "distinct1",
(all_types.decimal IS DISTINCT FROM $3) AS "distinct2",
(all_types.real IS DISTINCT FROM $4) AS "distinct3",
(all_types.numeric IS NOT DISTINCT FROM all_types.numeric) AS "not_distinct1",
(all_types.decimal IS NOT DISTINCT FROM $5) AS "not_distinct2",
(all_types.real IS NOT DISTINCT FROM $6) AS "not_distinct3",
(all_types.numeric < $7) AS "lt1",
(all_types.numeric < $8) AS "lt2",
(all_types.numeric > $9) AS "gt1",
(all_types.numeric > $10) AS "gt2",
TRUNC((all_types.decimal + all_types.decimal), $11) AS "add1",
TRUNC((all_types.decimal + $12), $13) AS "add2",
TRUNC((all_types.decimal - all_types.decimal_ptr), $14) AS "sub1",
TRUNC((all_types.decimal - $15), $16) AS "sub2",
TRUNC((all_types.decimal * all_types.decimal_ptr), $17) AS "mul1",
TRUNC((all_types.decimal * $18), $19) AS "mul2",
TRUNC((all_types.decimal / all_types.decimal_ptr), $20) AS "div1",
TRUNC((all_types.decimal / $21), $22) AS "div2",
TRUNC((all_types.decimal % all_types.decimal_ptr), $23) AS "mod1",
TRUNC((all_types.decimal % $24), $25) AS "mod2",
TRUNC(POWER(all_types.decimal, all_types.decimal_ptr), $26) AS "pow1",
TRUNC(POWER(all_types.decimal, $27), $28) AS "pow2",
TRUNC(ABS(all_types.decimal), $29) AS "abs",
TRUNC(POWER(all_types.decimal, $30), $31) AS "power",
TRUNC(SQRT(all_types.decimal), $32) AS "sqrt",
TRUNC(CBRT(all_types.decimal)::decimal, $33) AS "cbrt",
CEIL(all_types.real) AS "ceil",
FLOOR(all_types.real) AS "floor",
ROUND(all_types.decimal) AS "round1",
ROUND(all_types.decimal, all_types.integer) AS "round2",
SIGN(all_types.real) AS "sign",
TRUNC(all_types.decimal, $34) AS "trunc"
FROM test_sample.all_types
LIMIT $35;
`)
var dest []struct {
common.FloatExpressionTestResult `alias:"."`
}
err = query.Query(db, &dest)
assert.NilError(t, err)
//testutils.JsonPrint(dest)
testutils.AssertJSONFile(t, "./testdata/common/float_operators.json", dest)
}
func TestIntegerOperators(t *testing.T) {
@ -591,12 +640,12 @@ var allTypesRow0 = model.AllTypes{
Integer: 300,
BigintPtr: Int64Ptr(50000),
Bigint: 5000,
DecimalPtr: Float64Ptr(11.44),
Decimal: 11.44,
NumericPtr: Float64Ptr(55.77),
Numeric: 55.77,
RealPtr: Float32Ptr(99.1),
Real: 99.1,
DecimalPtr: Float64Ptr(1.11),
Decimal: 1.11,
NumericPtr: Float64Ptr(2.22),
Numeric: 2.22,
RealPtr: Float32Ptr(5.55),
Real: 5.55,
DoublePrecisionPtr: Float64Ptr(11111111.22),
DoublePrecision: 11111111.22,
Smallserial: 1,
@ -658,11 +707,11 @@ var allTypesRow1 = model.AllTypes{
BigintPtr: nil,
Bigint: 5000,
DecimalPtr: nil,
Decimal: 11.44,
Decimal: 1.11,
NumericPtr: nil,
Numeric: 55.77,
Numeric: 2.22,
RealPtr: nil,
Real: 99.1,
Real: 5.55,
DoublePrecisionPtr: nil,
DoublePrecision: 11111111.22,
Smallserial: 2,

View file

@ -0,0 +1,40 @@
package common
type FloatExpressionTestResult struct {
Eq1 *bool
Eq2 *bool
Eq3 *bool
Distinct1 *bool
Distinct2 *bool
Distinct3 *bool
NotDistinct1 *bool
NotDistinct2 *bool
NotDistinct3 *bool
Lt1 *bool
Lt2 *bool
Gt1 *bool
Gt2 *bool
Add1 *float64
Add2 *float64
Sub1 *float64
Sub2 *float64
Mul1 *float64
Mul2 *float64
Div1 *float64
Div2 *float64
Mod1 *float64
Mod2 *float64
Pow1 *float64
Pow2 *float64
Abs *float64
Power *float64
Sqrt *float64
Cbrt *float64
Ceil *float64
Floor *float64
Round1 *float64
Round2 *float64
Sign *float64
Trunc *float64
}

View file

@ -0,0 +1,76 @@
[
{
"Eq1": true,
"Eq2": false,
"Eq3": false,
"Distinct1": false,
"Distinct2": true,
"Distinct3": true,
"NotDistinct1": true,
"NotDistinct2": false,
"NotDistinct3": false,
"Lt1": true,
"Lt2": true,
"Gt1": false,
"Gt2": false,
"Add1": 2.22,
"Add2": 12.33,
"Sub1": 0,
"Sub2": -10.11,
"Mul1": 1.23,
"Mul2": 12.45,
"Div1": 1,
"Div2": 0.09,
"Mod1": 0,
"Mod2": 1.11,
"Pow1": 1.12,
"Pow2": 1.24,
"Abs": 1.11,
"Power": 1.24,
"Sqrt": 1.05,
"Cbrt": 1.03,
"Ceil": 6,
"Floor": 5,
"Round1": 1,
"Round2": 1.11,
"Sign": 1,
"Trunc": 1.1
},
{
"Eq1": true,
"Eq2": false,
"Eq3": false,
"Distinct1": false,
"Distinct2": true,
"Distinct3": true,
"NotDistinct1": true,
"NotDistinct2": false,
"NotDistinct3": false,
"Lt1": true,
"Lt2": true,
"Gt1": false,
"Gt2": false,
"Add1": 2.22,
"Add2": 12.33,
"Sub1": null,
"Sub2": -10.11,
"Mul1": null,
"Mul2": 12.45,
"Div1": null,
"Div2": 0.09,
"Mod1": null,
"Mod2": 1.11,
"Pow1": null,
"Pow2": 1.24,
"Abs": 1.11,
"Power": 1.24,
"Sqrt": 1.05,
"Cbrt": 1.03,
"Ceil": 6,
"Floor": 5,
"Round1": 1,
"Round2": 1.11,
"Sign": 1,
"Trunc": 1.1
}
]