Skip to content

Commit

Permalink
Merge pull request #105 from packrat386/fix_canonical_string
Browse files Browse the repository at this point in the history
Fix incorrect string comparison
  • Loading branch information
xeipuuv committed Jun 21, 2016
2 parents 8029392 + 7cde51b commit c395321
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions schema.go
Expand Up @@ -50,10 +50,10 @@ func NewSchema(l JSONLoader) (*Schema, error) {
d := Schema{}
d.pool = newSchemaPool(l.LoaderFactory())
d.documentReference = ref
d.referencePool=newSchemaReferencePool()
d.referencePool = newSchemaReferencePool()

var doc interface{}
if ref.String() != "#" {
if ref.String() != "" {
// Get document from schema pool
spd, err := d.pool.GetDocument(d.documentReference)
if err != nil {
Expand Down
28 changes: 28 additions & 0 deletions schema_test.go
Expand Up @@ -414,3 +414,31 @@ func TestJsonSchemaTestSuite(t *testing.T) {

fmt.Printf("\n%d tests performed / %d total tests to perform ( %.2f %% )\n", len(JsonSchemaTestSuiteMap), 248, float32(len(JsonSchemaTestSuiteMap))/248.0*100.0)
}

// From http://json-schema.org/examples.html
const simpleSchema = `{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}`

func TestNewStringLoader(t *testing.T) {
loader := NewStringLoader(simpleSchema)
_, err := NewSchema(loader)
if err != nil {
t.Errorf("Got error: %s", err.Error())
}
}

0 comments on commit c395321

Please sign in to comment.