edsrzf / go-bson Goto Github PK
View Code? Open in Web Editor NEWA BSON package for Go
A BSON package for Go
This test fails:
commit a4efd1d098814e3e6debb642d8b8ec758e9fa98b Author: Yves Junqueira Date: Thu Nov 25 01:02:58 2010 +0100 Test case showing a bug in go-bson for unmarshaling long array of integers diff --git a/bson_test.go b/bson_test.go index c4ad98e..7f913ce 100644 --- a/bson_test.go +++ b/bson_test.go @@ -35,6 +35,9 @@ var bsonTests = []struct { {Doc{"test": MaxKey{}}, []byte("\x0B\x00\x00\x00\x7Ftest\x00\x00")}, {Doc{"test": MinKey{}}, []byte("\x0B\x00\x00\x00\xFFtest\x00\x00")}, {Doc{"BSON": []interface{}{"awesome", float64(5.05), int32(1986)}}, []byte("\x31\x00\x00\x00\x04BSON\x00\x26\x00\x00\x00\x02\x30\x00\x08\x00\x00\x00awesome\x00\x01\x31\x + {Doc{"BSON": []int64{22055360, 12688462, 212446583, 37455565, 73465456, 17133954, 14786502, 51854974, 71727795, + 20146901, 167890598}}, + []byte("\x8a\x00\x00\x00\x04BSON\x00\x7f\x00\x00\x00\x120\x00\xc0\x89P\x01\x00\x00\x00\x00\x121\x00N\x9c\xc1\x00\x00\x00\x00\x00\x122\x00w\xad\xa9\f\x00\x00\x00\ } func TestMarshal(t *testing.T) {
--- FAIL: bson.TestUnmarshal #20 expected map[BSON:[22055360 12688462 212446583 37455565 73465456 17133954 14786502 51854974 71727795 20146901 167890598]] got map[BSON:[22055360 12688462 212446583 37455565 73465456 17133954 14786502 51854974 71727795 20146901 42979993088]] FAIL
If it helps debugging, I noticed this on line :94 of decode.go:
// discard key (always 1-byte string + nul log.Println("key", d.Next(2)) // (my own addition) var el interface{} el, err = d.decodeElem(kind)
When decoding the item that fails, that print shows something d.Next(2)[1] even though it's not expected:
...
(After adding log.Println() statements) 2010/11/25 01:07:59 key [55 0] 2010/11/25 01:07:59 element 51854974 2010/11/25 01:07:59 key [56 0] 2010/11/25 01:07:59 element 71727795 2010/11/25 01:07:59 key [57 0] 2010/11/25 01:07:59 element 20146901 2010/11/25 01:07:59 key [49 48] // <<== this 48 isn't expected, based on your comment. 2010/11/25 01:07:59 element 42979993088
Sorry for not being able to submit a patch with the fix - I couldn't figure this one out myself.
Cheers!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.