Skip to content

Commit 8828a9d

Browse files
Oliver 'ker' SchneiderOliver Schneider
authored andcommitted
---
yaml --- r: 182339 b: refs/heads/beta c: 0478a8c h: refs/heads/master i: 182337: 38cf07e 182335: 34564f8 v: v3
1 parent f8f5fe8 commit 8828a9d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: d727f9910729625039defffd4058b907ca984bb9
34+
refs/heads/beta: 0478a8c1d73ab936bcfb762ce8f31ab9f642f462
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: eb836bf767aa1d8d4cba488a9091cde3c0ab4b2f

branches/beta/src/libserialize/json.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2583,7 +2583,7 @@ mod tests {
25832583
use super::DecoderError::*;
25842584
use super::JsonEvent::*;
25852585
use super::{Json, from_str, DecodeResult, DecoderError, JsonEvent, Parser,
2586-
StackElement, Stack, Decoder};
2586+
StackElement, Stack, Decoder, Encoder, EncoderError};
25872587
use std::{i64, u64, f32, f64, io};
25882588
use std::collections::BTreeMap;
25892589
use std::num::Float;
@@ -3892,6 +3892,25 @@ mod tests {
38923892
assert_eq!(None::<int>.to_json(), Null);
38933893
}
38943894

3895+
#[test]
3896+
fn test_encode_hashmap_with_arbitrary_key() {
3897+
use std::str::from_utf8;
3898+
use std::io::Writer;
3899+
use std::collections::HashMap;
3900+
use std::fmt;
3901+
#[derive(PartialEq, Eq, Hash, RustcEncodable)]
3902+
struct ArbitraryType(uint);
3903+
let mut hm: HashMap<ArbitraryType, bool> = HashMap::new();
3904+
hm.insert(ArbitraryType(1), true);
3905+
let mut mem_buf = Vec::new();
3906+
let mut encoder = Encoder::new(&mut mem_buf as &mut fmt::Writer);
3907+
let result = hm.encode(&mut encoder);
3908+
match result.unwrap_err() {
3909+
EncoderError::BadHashmapKey => (),
3910+
_ => panic!("expected bad hash map key")
3911+
}
3912+
}
3913+
38953914
#[bench]
38963915
fn bench_streaming_small(b: &mut Bencher) {
38973916
b.iter( || {

0 commit comments

Comments
 (0)