You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2021/04/08 17:45:45 UTC

[plc4x] branch develop updated (036a157 -> f4e434c)

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git.


    from 036a157  fix: Made the NiFi modules use the PooledDriverManager more correctly.
     new 0146059  plc4go: finalized float64 tests for ReadBuffer_test.go
     new f4e434c  plc4j: reintroduced deleted types in test.mspec and disable them as they don't compile in java

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/resources/protocols/test/test.mspec   |  21 +-
 go.mod                                             |   2 +-
 go.sum                                             |   2 +
 .../internal/plc4go/spi/utils/ReadBuffer_test.go   | 602 ++++++++++++++++++++-
 4 files changed, 605 insertions(+), 22 deletions(-)

[plc4x] 01/02: plc4go: finalized float64 tests for ReadBuffer_test.go

Posted by sr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 01460594be74dde8e9e7f55f0ca94dfcc179ca23
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Apr 8 19:22:59 2021 +0200

    plc4go: finalized float64 tests for ReadBuffer_test.go
---
 .../internal/plc4go/spi/utils/ReadBuffer_test.go   | 602 ++++++++++++++++++++-
 1 file changed, 586 insertions(+), 16 deletions(-)

diff --git a/plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go b/plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go
index 54adb60..435b3fb 100644
--- a/plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go
+++ b/plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go
@@ -603,13 +603,241 @@ func TestReadBuffer_ReadFloat64(t *testing.T) {
 		},
 		// Section 2
 		/*
-		   TODO 0 10000000000 10000000000000000000000000000000000000000000000000002 ≙ 4008 0000 0000 0000 16 ≙ +2^1 × 1.12 = 112 = 3
-		   TODO 0 10000000001 00000000000000000000000000000000000000000000000000002 ≙ 4010 0000 0000 0000 16 ≙ +2^2 × 1 = 1002 = 4
-		   TODO 0 10000000001 01000000000000000000000000000000000000000000000000002 ≙ 4014 0000 0000 0000 16 ≙ +2^2 × 1.012 = 1012 = 5
-		   TODO 0 10000000001 10000000000000000000000000000000000000000000000000002 ≙ 4018 0000 0000 0000 16 ≙ +2^2 × 1.12 = 1102 = 6
-		   TODO 0 10000000011 01110000000000000000000000000000000000000000000000002 ≙ 4037 0000 0000 0000 16 ≙ +2^4 × 1.01112 = 101112 = 23
-		   TODO 0 01111111000 10000000000000000000000000000000000000000000000000002 ≙ 3F88 0000 0000 0000 16 ≙ +2^−7 × 1.12 = 0.000000112 = 0.01171875 (3/256)
+		   0 10000000000 10000000000000000000000000000000000000000000000000002 ≙ 4008 0000 0000 0000 16 ≙ +2^1 × 1.1_2 = 11_2 = 3
+		   0 10000000001 00000000000000000000000000000000000000000000000000002 ≙ 4010 0000 0000 0000 16 ≙ +2^2 × 1 = 1002 = 4
+		   0 10000000001 01000000000000000000000000000000000000000000000000002 ≙ 4014 0000 0000 0000 16 ≙ +2^2 × 1.012 = 1012 = 5
+		   0 10000000001 10000000000000000000000000000000000000000000000000002 ≙ 4018 0000 0000 0000 16 ≙ +2^2 × 1.12 = 1102 = 6
+		   0 10000000011 01110000000000000000000000000000000000000000000000002 ≙ 4037 0000 0000 0000 16 ≙ +2^4 × 1.01112 = 101112 = 23
+		   0 01111111000 10000000000000000000000000000000000000000000000000002 ≙ 3F88 0000 0000 0000 16 ≙ +2^−7 × 1.12 = 0.000000112 = 0.01171875 (3/256)
 		*/
+		{
+			name: "+2^1 × 1.12 = 112 = 3",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    3,
+			wantErr: false,
+		},
+		{
+			name: "+2^1 × 1.12 = 112 = 3 LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    3,
+			wantErr: false,
+		},
+		{
+			name: "+2^2 × 1 = 1002 = 4",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    4,
+			wantErr: false,
+		},
+		{
+			name: "+2^2 × 1 = 1002 = 4 LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    4,
+			wantErr: false,
+		},
+		{
+			name: "+2^2 × 1.012 = 1012 = 5",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    5,
+			wantErr: false,
+		},
+		{
+			name: "+2^2 × 1.012 = 1012 = 5 LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x40})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    5,
+			wantErr: false,
+		},
+		{
+			name: "+2^2 × 1.12 = 1102 = 6",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x40, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    6,
+			wantErr: false,
+		},
+		{
+			name: "+2^2 × 1.12 = 1102 = 6 LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    6,
+			wantErr: false,
+		},
+		{
+			name: "+2^4 × 1.01112 = 101112 = 23",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x40, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    23,
+			wantErr: false,
+		},
+		{
+			name: "+2^4 × 1.01112 = 101112 = 23 LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x40})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    23,
+			wantErr: false,
+		},
+		{
+			name: "+2^4 × 1.01112 = 101112 = 23",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x3F, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    0.01171875,
+			wantErr: false,
+		},
+		{
+			name: "+2^−7 × 1.12 = 0.000000112 = 0.01171875 (3/256) LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x3F})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    0.01171875,
+			wantErr: false,
+		},
 		// Section 3
 		/*
 			0 00000000000 00000000000000000000000000000000000000000000000000012 ≙ 0000 0000 0000 0001 16 ≙ +2^−1022 × 2^−52 = 2^−1074 ≈ 4.9406564584124654 × 10^−324 (Min. subnormal positive double)
@@ -771,22 +999,364 @@ func TestReadBuffer_ReadFloat64(t *testing.T) {
 		},
 		// Section 4
 		/*
-			TODO 0 00000000000 00000000000000000000000000000000000000000000000000002 ≙ 0000 0000 0000 000016 ≙ +0
-			TODO 1 00000000000 00000000000000000000000000000000000000000000000000002 ≙ 8000 0000 0000 000016 ≙ −0
-			TODO 0 11111111111 00000000000000000000000000000000000000000000000000002 ≙ 7FF0 0000 0000 000016 ≙ +∞ (positive infinity)
-			TODO 1 11111111111 00000000000000000000000000000000000000000000000000002 ≙ FFF0 0000 0000 000016 ≙ −∞ (negative infinity)
-			TODO 0 11111111111 00000000000000000000000000000000000000000000000000012 ≙ 7FF0 0000 0000 000116 ≙ NaN (sNaN on most processors, such as x86 and ARM)
-			TODO 0 11111111111 10000000000000000000000000000000000000000000000000012 ≙ 7FF8 0000 0000 000116 ≙ NaN (qNaN on most processors, such as x86 and ARM)
-			TODO 0 11111111111 11111111111111111111111111111111111111111111111111112 ≙ 7FFF FFFF FFFF FFFF16 ≙ NaN (an alternative encoding of NaN)
+				0 00000000000 00000000000000000000000000000000000000000000000000002 ≙ 0000 0000 0000 0000 16 ≙ +0
+				    1 00000000000 00000000000000000000000000000000000000000000000000002 ≙ 8000 0000 0000 0000 16 ≙ −0
+				    0 11111111111 00000000000000000000000000000000000000000000000000002 ≙ 7FF0 0000 0000 0000 16 ≙ +∞ (positive infinity)
+				    1 11111111111 00000000000000000000000000000000000000000000000000002 ≙ FFF0 0000 0000 0000 16 ≙ −∞ (negative infinity)
+		            0 11111111111 00000000000000000000000000000000000000000000000000012 ≙ 7FF0 0000 0000 0001 16 ≙ NaN (sNaN on most processors, such as x86 and ARM)
+				    0 11111111111 10000000000000000000000000000000000000000000000000012 ≙ 7FF8 0000 0000 0001 16 ≙ NaN (qNaN on most processors, such as x86 and ARM)
+					0 11111111111 11111111111111111111111111111111111111111111111111112 ≙ 7FFF FFFF FFFF FFFF 16 ≙ NaN (an alternative encoding of NaN)
 		*/
 		// Section 5
+		{
+			name: "+0",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    0,
+			wantErr: false,
+		},
+		{
+			name: "+0 LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    0,
+			wantErr: false,
+		},
+		{
+			name: "−0",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.SmallestNonzeroFloat64,
+			wantErr: false,
+		},
+		{
+			name: "−0 LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.SmallestNonzeroFloat64,
+			wantErr: false,
+		},
+		{
+			name: "−∞ (positive infinity))",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.Inf(1),
+			wantErr: false,
+		},
+		{
+			name: "−∞ (positive infinity) LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7F})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.Inf(1),
+			wantErr: false,
+		},
+		{
+			name: "−∞ (negative infinity))",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.Inf(-1),
+			wantErr: false,
+		},
+		{
+			name: "−∞ (negative infinity) LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.Inf(-1),
+			wantErr: false,
+		},
+		{
+			name: "NaN (sNaN on most processors, such as x86 and ARM)",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.NaN(),
+			wantErr: false,
+		},
+		{
+			name: "NaN (sNaN on most processors, such as x86 and ARM) LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x01, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7F})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.NaN(),
+			wantErr: false,
+		},
+		{
+			name: "NaN (qNaN on most processors, such as x86 and ARM)",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.NaN(),
+			wantErr: false,
+		},
+		{
+			name: "NaN (qNaN on most processors, such as x86 and ARM) LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x01, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x7F})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.NaN(),
+			wantErr: false,
+		},
+		{
+			name: "NaN (an alternative encoding of NaN)",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.NaN(),
+			wantErr: false,
+		},
+		{
+			name: "NaN (an alternative encoding of NaN) LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.NaN(),
+			wantErr: false,
+		},
 		/*
-			TODO 0 01111111101 01010101010101010101010101010101010101010101010101012 = 3FD5 5555 5555 555516 ≙ +2−2 × (1 + 2−2 + 2−4 + ... + 2−52) ≈ 1/3
+			0 01111111101 01010101010101010101010101010101010101010101010101012 = 3FD5 5555 5555 555516 ≙ +2−2 × (1 + 2−2 + 2−4 + ... + 2−52) ≈ 1/3
 		*/
+		{
+			name: "+2−2 × (1 + 2−2 + 2−4 + ... + 2−52) ≈ 1/3",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x3F, 0xD5, 0x55, 0x55, 0x55, 0x55, 0x55, 0x16})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    1.0 / 3.0,
+			wantErr: false,
+		},
+		{
+			name: "+2−2 × (1 + 2−2 + 2−4 + ... + 2−52) ≈ 1/3 LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x16, 0x55, 0x55, 0x55, 0x55, 0x55, 0xD5, 0x3F})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    1.0 / 3.0,
+			wantErr: false,
+		},
 		// Section 6
 		/*
-			TODO 0 10000000000 10010010000111111011010101000100010000101101000110002 = 4009 21FB 5444 2D1816 ≈ pi
+		  0 10000000000 10010010000111111011010101000100010000101101000110002 = 4009 21FB 5444 2D18 16 ≈ pi
 		*/
+		{
+			name: "pi",
+			fields: func() fields {
+				buffer := NewReadBuffer([]byte{0x40, 0x09, 0x21, 0xFB, 0x54, 0x44, 0x2D, 0x18})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.Pi,
+			wantErr: false,
+		},
+		{
+			name: "pi LE",
+			fields: func() fields {
+				buffer := NewLittleEndianReadBuffer([]byte{0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40})
+				return fields{
+					data:      buffer.data,
+					reader:    buffer.reader,
+					pos:       buffer.pos,
+					byteOrder: buffer.byteOrder,
+				}
+			}(),
+			args: args{
+				signed:            true,
+				exponentBitLength: 11,
+				mantissaBitLength: 52,
+			},
+			want:    math.Pi,
+			wantErr: false,
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
@@ -801,7 +1371,7 @@ func TestReadBuffer_ReadFloat64(t *testing.T) {
 				t.Errorf("ReadFloat64() error = %v, wantErr %v", err, tt.wantErr)
 				return
 			}
-			tolerance := 0.0000000000000001
+			tolerance := 0.0000000000001
 			if diff := math.Abs(got - tt.want); diff > tolerance {
 				t.Errorf("ReadFloat64() got = %v, want %v. Diff %v with tolerance of %v", got, tt.want, diff, tolerance)
 			}

[plc4x] 02/02: plc4j: reintroduced deleted types in test.mspec and disable them as they don't compile in java

Posted by sr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit f4e434cc746790caf553425ca8c0083887aa1a1a
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Apr 8 19:36:13 2021 +0200

    plc4j: reintroduced deleted types in test.mspec and disable them as they don't compile in java
---
 .../src/main/resources/protocols/test/test.mspec    | 21 ++++++++++++++++-----
 go.mod                                              |  2 +-
 go.sum                                              |  2 ++
 plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go | 14 +++++++-------
 4 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/build-utils/protocol-test/src/main/resources/protocols/test/test.mspec b/build-utils/protocol-test/src/main/resources/protocols/test/test.mspec
index dac2e6e..91e091c 100644
--- a/build-utils/protocol-test/src/main/resources/protocols/test/test.mspec
+++ b/build-utils/protocol-test/src/main/resources/protocols/test/test.mspec
@@ -51,11 +51,22 @@
     //[typeSwitch 'simpleField' ]
 ]
 
-//[simple time 'timeField']
-
-//[simple date 'dateField']
-
-//[simple dateTime 'dateTimeField']
+/*
+ * TODO: doesn't compile in java
+[type 'UFloatTypeTest'
+    [simple ufloat 8.23 'ufloatField']
+    [simple ufloat 11.52 'udoubleField']
+]
+*/
+
+/*
+ * TODO: doesn't compile in java
+[type 'TimeTypeTest'
+    [simple time 8 'timeField']
+    [simple date 8 'dateField']
+    [simple dateTime 8 'dateTimeField']
+]
+*/
 
 [type 'SimpleTypeTest'
     [simple bit 'bitField']
diff --git a/go.mod b/go.mod
index f0f86b0..6e06e33 100644
--- a/go.mod
+++ b/go.mod
@@ -21,6 +21,6 @@ module github.com/apache/plc4x
 go 1.15
 
 require (
-	github.com/apache/plc4x/plc4go v0.0.0-20210407074126-e5b4b44da317 // indirect
+	github.com/apache/plc4x/plc4go v0.0.0-20210408143516-036a157857da // indirect
 	github.com/sirupsen/logrus v1.7.0 // indirect
 )
diff --git a/go.sum b/go.sum
index 334f106..6457c41 100644
--- a/go.sum
+++ b/go.sum
@@ -34,6 +34,8 @@ github.com/apache/plc4x/plc4go v0.0.0-20210407063940-121856ba233a h1:c7LNsPEMtAL
 github.com/apache/plc4x/plc4go v0.0.0-20210407063940-121856ba233a/go.mod h1:NfO8uGKPGwDxn1GqOb4oNhAtPF7St1A9LRk1J/qSlWU=
 github.com/apache/plc4x/plc4go v0.0.0-20210407074126-e5b4b44da317 h1:uWyhOLCZzX2WBWjq7IOvmq1x0itW4e1ogqFHVHRESE4=
 github.com/apache/plc4x/plc4go v0.0.0-20210407074126-e5b4b44da317/go.mod h1:NfO8uGKPGwDxn1GqOb4oNhAtPF7St1A9LRk1J/qSlWU=
+github.com/apache/plc4x/plc4go v0.0.0-20210408143516-036a157857da h1:F9LSM9eVziaw1DpevUCDd/l0wBs2pHJG5ebM/LzOFUo=
+github.com/apache/plc4x/plc4go v0.0.0-20210408143516-036a157857da/go.mod h1:NfO8uGKPGwDxn1GqOb4oNhAtPF7St1A9LRk1J/qSlWU=
 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
diff --git a/plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go b/plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go
index 435b3fb..44dce6a 100644
--- a/plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go
+++ b/plc4go/internal/plc4go/spi/utils/ReadBuffer_test.go
@@ -999,13 +999,13 @@ func TestReadBuffer_ReadFloat64(t *testing.T) {
 		},
 		// Section 4
 		/*
-				0 00000000000 00000000000000000000000000000000000000000000000000002 ≙ 0000 0000 0000 0000 16 ≙ +0
-				    1 00000000000 00000000000000000000000000000000000000000000000000002 ≙ 8000 0000 0000 0000 16 ≙ −0
-				    0 11111111111 00000000000000000000000000000000000000000000000000002 ≙ 7FF0 0000 0000 0000 16 ≙ +∞ (positive infinity)
-				    1 11111111111 00000000000000000000000000000000000000000000000000002 ≙ FFF0 0000 0000 0000 16 ≙ −∞ (negative infinity)
-		            0 11111111111 00000000000000000000000000000000000000000000000000012 ≙ 7FF0 0000 0000 0001 16 ≙ NaN (sNaN on most processors, such as x86 and ARM)
-				    0 11111111111 10000000000000000000000000000000000000000000000000012 ≙ 7FF8 0000 0000 0001 16 ≙ NaN (qNaN on most processors, such as x86 and ARM)
-					0 11111111111 11111111111111111111111111111111111111111111111111112 ≙ 7FFF FFFF FFFF FFFF 16 ≙ NaN (an alternative encoding of NaN)
+			0 00000000000 00000000000000000000000000000000000000000000000000002 ≙ 0000 0000 0000 0000 16 ≙ +0
+			1 00000000000 00000000000000000000000000000000000000000000000000002 ≙ 8000 0000 0000 0000 16 ≙ −0
+			0 11111111111 00000000000000000000000000000000000000000000000000002 ≙ 7FF0 0000 0000 0000 16 ≙ +∞ (positive infinity)
+			1 11111111111 00000000000000000000000000000000000000000000000000002 ≙ FFF0 0000 0000 0000 16 ≙ −∞ (negative infinity)
+			0 11111111111 00000000000000000000000000000000000000000000000000012 ≙ 7FF0 0000 0000 0001 16 ≙ NaN (sNaN on most processors, such as x86 and ARM)
+			0 11111111111 10000000000000000000000000000000000000000000000000012 ≙ 7FF8 0000 0000 0001 16 ≙ NaN (qNaN on most processors, such as x86 and ARM)
+			0 11111111111 11111111111111111111111111111111111111111111111111112 ≙ 7FFF FFFF FFFF FFFF 16 ≙ NaN (an alternative encoding of NaN)
 		*/
 		// Section 5
 		{