Comments (6)
I resolved issue with my code so thanks you again
from data-encoding.
Hi, thanks for reaching out!
Could you provide me a bit more information about what you're trying to do exactly? Ideally with code pointers and example data input and output. In particular, which tag number of CBOR are you concerned about? 21, 22, 33, and 34 seem to be the relevant ones.
Thanks!
from data-encoding.
Thanks for fast reply!
I want to write tests checks if CBOR/RFC 8949 implementation correct. As I understand bytes in writter is correct and issue when I'm creating hex representation.
#[test]
fn check_unsigned_int()
{
// Examples come from RFC8949, Appendix A
let var =
[
( 0_u64, "00" ),
( 1, "01" ),
( 10, "0a"),
( 23, "17"),
( 24, "1818"),
( 25, "1819"),
( 100, "1864" ),
( 1000, "1903e8"),
( 1000000, "1a000f4240"),
( 1000000000000, "1b000000e8d4a51000"),
( 18446744073709551615, "1bffffffffffffffff" ),
];
validate_result( var )
}
fn validate_result<T : Cbor>(value : impl IntoIterator<Item = (T, &'static str)>)
{
for ( i, expected ) in value
{
let mut buf = Vec::new();
i.encode(&mut buf).expect(&format!( "Failed to write buffer for {}", i));
let hex = data_encoding::HEXLOWER.encode( &buf );
assert_eq!( &hex, expected );
}
}
assertion `left == right` failed
left: "1900000000000003e8"
right: "1903e8"
from data-encoding.
Thanks for the code. This looks to me like a problem in the CBOR encoding. You can see it by comparing at the byte level instead of the hexadecimal representation.
-let hex = data_encoding::HEXLOWER.encode( &buf );
-assert_eq!( &hex, expected );
+let expected = data_encoding::HEXLOWER.decode(expected.as_bytes()).unwrap();
+assert_eq!(buf, expected, "{buf:02x?} != {expected:02x?}");
from data-encoding.
I forget that I may compare bytes representation. Thanks for that!
from data-encoding.
Perfect, thanks a lot for the feedback!
from data-encoding.
Related Issues (20)
- no-std support for macro crate
- Macros Won't Build in no_std HOT 4
- (std -> core)::fmt::Display for DecodeError and DecodeKind HOT 2
- feature `std` leaking when using macro in no_std env HOT 7
- Missing a new line and decode error HOT 2
- Rust 2021 edition is a major, not a "patch" change HOT 6
- Removing dependency on syn HOT 7
- Make `{encode,decode}_len` const fns? HOT 4
- Encode into an "impl std::fmt::Write" and/or "impl std::io::Write" HOT 5
- Breaking change wish list
- Use doc_auto_cfg once stable HOT 2
- Use as_chunks family of functions once stable
- Internal symbols array is publicly exposed and unsound HOT 4
- Deny warnings in rustdoc
- Partial encoding with padding HOT 3
- Release 2.5.0
- SIMD optimization HOT 4
- `Encoding::encode_mut` is very code-size heavy HOT 15
- feature request - base58 d/encoding HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data-encoding.