Allow dictionary values to be null #7

Merged
merged 1 commit into from Jun 21, 2011
View
1 lib/tnetstring.rb
@@ -85,7 +85,6 @@ def self.parse_pair(data) # :nodoc:
assert key.kind_of?(String) || key.kind_of?(Symbol), "Dictionary keys must be Strings or Symbols"
assert extra, "Unbalanced dictionary store"
value, extra = parse(extra)
- assert value, "Got an invalid value, null not allowed"
[key, value, extra]
end
View
4 spec/tnetstring_spec.rb
@@ -34,6 +34,10 @@
TNetstring.parse('0:~')[0].should == nil
end
+ it "parses a dictionary with a null value" do
+ TNetstring.parse("9:3:key,0:~}")[0].should == {"key" => nil}
+ end
+
it "raises on a lengthy null" do
expect { TNetstring.parse('1:x~')[0] }.to raise_error(TNetstring::ProcessError)
end