Skip to content

Commit

Permalink
Added test for good after bad deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
its-luca committed Aug 22, 2022
1 parent d5a9d94 commit 26afbc3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
46 changes: 41 additions & 5 deletions bibtex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,50 @@ func TestParser(t *testing.T) {

// TestParser_ErrorHandling checks that the parser returns an error value for malformed bibtex
func TestParser_ErrorHandling(t *testing.T) {
input := `
@inproceedings{A,
title = thisIsInvalid,
examples, err := filepath.Glob("example/*.badbib")
if err != nil {
t.Fatal(err)
}

for _, ex := range examples {
t.Logf("Parsing example: %s", ex)
b, err := ioutil.ReadFile(ex)
if err != nil {
t.Errorf("Cannot read %s: %v", ex, err)
}
_, err = Parse(bytes.NewReader(b))
if err == nil {
t.Fatalf("Expected parser error got none")
}
}

}

// TestParser_ErrorHandling checks that the parser returns an error value for malformed bibtex
func TestParser_ParseGoodEntryAfterBadEntry(t *testing.T) {
goodEntry := `@article{agneroptimize,
title={The microarchitecture of Intel, AMD and VIA CPUs: An optimization guide for assembly programmers and compiler makers},
author={Fog, Agner},
journal={Copenhagen University College of Engineering},
pages={02--29},
year={2012}
}`
_, err := Parse(strings.NewReader(input))
badEntry := `@article{agneroptimize,
title={The microarchitecture of Intel, AMD and VIA CPUs: An optimization guide for assembly programmers and compiler makers},
author={Fog, Agner},
journal=Copenhagen University College of Engineering,
pages={02--29},
year={2012}
}`

_, err := Parse(strings.NewReader(badEntry))
if err == nil {
t.Fatalf("Expected parser error got none")
t.Fatal("Expected parser error got none")
}

_, err = Parse(strings.NewReader(goodEntry))
if err != nil {
t.Fatalf("Did not expect parser error but got %v", err)
}

}
Expand Down
7 changes: 7 additions & 0 deletions example/unquoted-string-complex.badbib
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@article{agneroptimize,
title={The microarchitecture of Intel, AMD and VIA CPUs: An optimization guide for assembly programmers and compiler makers},
author={Fog, Agner},
journal=Copenhagen University College of Engineering,
pages={02--29},
year={2012}
}
4 changes: 4 additions & 0 deletions example/unquoted-string-simple.badbib
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@inproceedings{A,
title = thisIsInvalid,

}`

0 comments on commit 26afbc3

Please sign in to comment.