Skip to content

Commit

Permalink
Add test case to support comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nickng committed Dec 12, 2023
1 parent bc6976e commit d179189
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bibtex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestParser(t *testing.T) {

for _, ex := range examples {
t.Logf("Parsing example: %s", ex)
b, err := ioutil.ReadFile(ex)
b, err := os.ReadFile(ex)
if err != nil {
t.Errorf("Cannot read %s: %v", ex, err)
}
Expand All @@ -89,12 +89,13 @@ func TestMultiParse(t *testing.T) {
"example/simple.bib",
"example/simple.bib",
"example/simple.bib",
"example/simple2.bib", // simple but with comment
}

var bibs []*BibTex
for _, ex := range examples {
t.Logf("Parsing example: %s", ex)
b, err := ioutil.ReadFile(ex)
b, err := os.ReadFile(ex)
if err != nil {
t.Errorf("Cannot read %s: %v", ex, err)
}
Expand Down Expand Up @@ -122,7 +123,7 @@ func TestPrettyStringRoundTrip(t *testing.T) {

for _, ex := range examples {
// Read input.
b, err := ioutil.ReadFile(ex)
b, err := os.ReadFile(ex)
if err != nil {
t.Fatal(err)
}
Expand All @@ -148,7 +149,7 @@ func TestPrettyStringRoundTrip(t *testing.T) {

func TestUnexpectedAtSign(t *testing.T) {
// Tests correct syntax but scanning error
b, err := ioutil.ReadFile("example/unexpected-at-sign.badbib")
b, err := os.ReadFile("example/unexpected-at-sign.badbib")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -191,7 +192,7 @@ func AssertEntriesEqual(t *testing.T, a, b *BibEntry) {
}

func BenchmarkStringPerformance(b *testing.B) {
exampleFileBytes, err := ioutil.ReadFile("example/biblatex-examples.bib")
exampleFileBytes, err := os.ReadFile("example/biblatex-examples.bib")
if err != nil {
b.Fatal(err)
}
Expand Down
16 changes: 16 additions & 0 deletions example/simple2.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@article{name,
year = 2016,
title = {SessionBasedBlah}
}

@comment{
this looks like an entry
but is actually a comment
even if the braces don't
balance it's still valid {}

@inproceedings{ng2014,
title = "Blah",
author = "Me",
booktitle = "ABCD2014"
}

0 comments on commit d179189

Please sign in to comment.