()
| 228 | //TODO: move where it fits better |
| 229 | #[test] |
| 230 | fn test_enum_string_value() { |
| 231 | let raw_schema = r#" |
| 232 | { |
| 233 | "type": "record", |
| 234 | "name": "test", |
| 235 | "fields": [ |
| 236 | {"name": "a", "type": "long", "default": 42}, |
| 237 | {"name": "b", "type": "string"}, |
| 238 | { |
| 239 | "name": "c", |
| 240 | "type": { |
| 241 | "type": "enum", |
| 242 | "name": "suit", |
| 243 | "symbols": ["diamonds", "spades", "clubs", "hearts"] |
| 244 | }, |
| 245 | "default": "spades" |
| 246 | } |
| 247 | ] |
| 248 | } |
| 249 | "#; |
| 250 | let schema = Schema::parse_str(raw_schema).unwrap(); |
| 251 | let mut writer = Writer::with_codec(&schema, Vec::new(), Codec::Null).unwrap(); |
| 252 | let mut record = Record::new(writer.schema()).unwrap(); |
| 253 | record.put("a", 27i64); |
| 254 | record.put("b", "foo"); |
| 255 | record.put("c", "clubs"); |
| 256 | writer.append_value(record).unwrap(); |
| 257 | let input = writer.into_inner().unwrap(); |
| 258 | let mut reader = Reader::builder(&input[..]) |
| 259 | .reader_schema(&schema) |
| 260 | .build() |
| 261 | .unwrap(); |
| 262 | assert_eq!( |
| 263 | reader.next().unwrap().unwrap(), |
| 264 | Value::Record(vec![ |
| 265 | ("a".to_string(), Value::Long(27)), |
| 266 | ("b".to_string(), Value::String("foo".to_string())), |
| 267 | ("c".to_string(), Value::Enum(2, "clubs".to_string())), |
| 268 | ]) |
| 269 | ); |
| 270 | assert!(reader.next().is_none()); |
| 271 | } |
| 272 | |
| 273 | //TODO: move where it fits better |
| 274 | #[test] |
nothing calls this directly
no test coverage detected