aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/lunixbochs/struc/custom_float16_test.go
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2019-01-10 10:57:50 +0100
committerOndrej Fabry <ofabry@cisco.com>2019-01-10 11:05:35 +0100
commit08266e35878f198e2fa59fcfc9f0fc3a4b1dfbf5 (patch)
tree1269acfc3bf6fdd47414eb64da3ecad4865e37d6 /vendor/github.com/lunixbochs/struc/custom_float16_test.go
parent3ef6f210edcf7dd753733d46ec3f2dd5dc795b61 (diff)
Add support for string types
- strings are now generated as two fields for length and string itself - aliases are now sorted by name to prevent generating different code - dependencies are now managed by dep - binapi files are regenerated using VPP 19.01-rc0~622-g7b01e9e8 - old stats binary api has been deprecated and removed from VPP Change-Id: Ieb8515c73021339a45f407386f8e3d87dcf4469e Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'vendor/github.com/lunixbochs/struc/custom_float16_test.go')
-rw-r--r--vendor/github.com/lunixbochs/struc/custom_float16_test.go56
1 files changed, 0 insertions, 56 deletions
diff --git a/vendor/github.com/lunixbochs/struc/custom_float16_test.go b/vendor/github.com/lunixbochs/struc/custom_float16_test.go
deleted file mode 100644
index 11f73cb..0000000
--- a/vendor/github.com/lunixbochs/struc/custom_float16_test.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package struc
-
-import (
- "bytes"
- "encoding/binary"
- "fmt"
- "math"
- "strconv"
- "strings"
- "testing"
-)
-
-func TestFloat16(t *testing.T) {
- // test cases from https://en.wikipedia.org/wiki/Half-precision_floating-point_format#Half_precision_examples
- tests := []struct {
- B string
- F float64
- }{
- //s expnt significand
- {"0 01111 0000000000", 1},
- {"0 01111 0000000001", 1.0009765625},
- {"1 10000 0000000000", -2},
- {"0 11110 1111111111", 65504},
- // {"0 00001 0000000000", 0.0000610352},
- // {"0 00000 1111111111", 0.0000609756},
- // {"0 00000 0000000001", 0.0000000596046},
- {"0 00000 0000000000", 0},
- // {"1 00000 0000000000", -0},
- {"0 11111 0000000000", math.Inf(1)},
- {"1 11111 0000000000", math.Inf(-1)},
- {"0 01101 0101010101", 0.333251953125},
- }
- for _, test := range tests {
- var buf bytes.Buffer
- f := Float16(test.F)
- if err := Pack(&buf, &f); err != nil {
- t.Error("pack failed:", err)
- continue
- }
- bitval, _ := strconv.ParseUint(strings.Replace(test.B, " ", "", -1), 2, 16)
- tmp := binary.BigEndian.Uint16(buf.Bytes())
- if tmp != uint16(bitval) {
- t.Errorf("incorrect pack: %s != %016b (%f)", test.B, tmp, test.F)
- continue
- }
- var f2 Float16
- if err := Unpack(&buf, &f2); err != nil {
- t.Error("unpack failed:", err)
- continue
- }
- // let sprintf deal with (im)precision for me here
- if fmt.Sprintf("%f", f) != fmt.Sprintf("%f", f2) {
- t.Errorf("incorrect unpack: %016b %f != %f", bitval, f, f2)
- }
- }
-}