func (s *S) TestStringSuccess(c *C) { v := "null" value, err := P.Parse(P.String(v), srd(v)) c.Assert(err, IsNil) c.Assert(value, FitsTypeOf, v) c.Assert(value, Equals, "null") }
func (s *S) TestBasicJson(c *C) { value, err := P.Parse(JsonObject, srd(`{"key":"value"}`)) c.Assert(err, IsNil) c.Assert(value, DeepEquals, map[string]interface{}{"key": "value"}) }
func (s *S) TestStringFailure(c *C) { value, err := P.Parse(P.String("null"), srd("facebook")) c.Assert(err, NotNil) c.Assert(value, Equals, nil) }
func (s *S) TestByteSuccess(c *C) { value, err := P.Parse(P.Byte(':'), srd(":symbol")) c.Assert(err, IsNil) c.Assert(value, Equals, byte(':')) }
func (s *S) TestByteFailure(c *C) { value, err := P.Parse(P.Byte(':'), srd("batman")) c.Assert(err, NotNil) c.Assert(value, Equals, nil) }
func (s *S) TestOrSuccessRest(c *C) { p := P.Or(P.String("batman"), P.String("robin")) value, err := P.Parse(p, srd("robin")) c.Assert(err, IsNil) c.Assert(value, Equals, "robin") }
func (s *S) TestOrFailure(c *C) { p := P.Or(P.String("batman"), P.String("robin")) value, err := P.Parse(p, srd("joker")) c.Assert(err, NotNil) c.Assert(value, Equals, nil) }