Code Monkey home page Code Monkey logo

go-bson's People

Contributors

edsrzf avatar nictuku avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-bson's Issues

Problem unmarshaling long array of integers

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.