Esempio n. 1
0
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")
}
Esempio n. 2
0
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"})
}
Esempio n. 3
0
func (s *S) TestStringFailure(c *C) {
	value, err := P.Parse(P.String("null"), srd("facebook"))
	c.Assert(err, NotNil)
	c.Assert(value, Equals, nil)
}
Esempio n. 4
0
func (s *S) TestByteSuccess(c *C) {
	value, err := P.Parse(P.Byte(':'), srd(":symbol"))
	c.Assert(err, IsNil)
	c.Assert(value, Equals, byte(':'))
}
Esempio n. 5
0
func (s *S) TestByteFailure(c *C) {
	value, err := P.Parse(P.Byte(':'), srd("batman"))
	c.Assert(err, NotNil)
	c.Assert(value, Equals, nil)
}
Esempio n. 6
0
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")
}
Esempio n. 7
0
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)
}