Skip to content

Commit 66ddf6c

Browse files
authored
test: support float32 in mock server (#2937)
Adds support for `float32` to the mock server for testing. Also adds a couple of tests that can be used to verify that the mock server supports all types, and that verifies that the client library reads and encodes all types correctly. These tests can be overridden by frameworks using the Java client (e.g. JDBC and PGAdapter) to verify that these also handle these types correctly when used through the API of that tool (I.e. through JDBC or PostgreSQL wire-protocol).
1 parent ccb110a commit 66ddf6c

File tree

2 files changed

+696
-0
lines changed

2 files changed

+696
-0
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,7 @@ private Statement buildStatement(
12861286
break;
12871287
case FLOAT32:
12881288
builder.bind(fieldName).toFloat32Array((Iterable<Float>) null);
1289+
break;
12891290
case FLOAT64:
12901291
builder.bind(fieldName).toFloat64Array((Iterable<Double>) null);
12911292
break;
@@ -1331,6 +1332,7 @@ private Statement buildStatement(
13311332
break;
13321333
case FLOAT32:
13331334
builder.bind(fieldName).to((Float) null);
1335+
break;
13341336
case FLOAT64:
13351337
builder.bind(fieldName).to((Double) null);
13361338
break;
@@ -1396,6 +1398,14 @@ private Statement buildStatement(
13961398
GrpcStruct.decodeArrayValue(
13971399
com.google.cloud.spanner.Type.date(), value.getListValue()));
13981400
break;
1401+
case FLOAT32:
1402+
builder
1403+
.bind(fieldName)
1404+
.toFloat32Array(
1405+
(Iterable<Float>)
1406+
GrpcStruct.decodeArrayValue(
1407+
com.google.cloud.spanner.Type.float32(), value.getListValue()));
1408+
break;
13991409
case FLOAT64:
14001410
builder
14011411
.bind(fieldName)
@@ -1479,6 +1489,9 @@ private Statement buildStatement(
14791489
case DATE:
14801490
builder.bind(fieldName).to(Date.parseDate(value.getStringValue()));
14811491
break;
1492+
case FLOAT32:
1493+
builder.bind(fieldName).to((float) value.getNumberValue());
1494+
break;
14821495
case FLOAT64:
14831496
builder.bind(fieldName).to(value.getNumberValue());
14841497
break;

0 commit comments

Comments
 (0)