Skip to content

Commit 6b6df36

Browse files
authored
Merge pull request #1039 from CraftSpider/more-bibtests
Add a bunch more bibtex tests
2 parents e6c8049 + acb9744 commit 6b6df36

38 files changed

Lines changed: 274 additions & 12 deletions

crates/engine_bibtex/bibtex/bibtex.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7278,6 +7278,7 @@ initialize(const char *aux_file_name)
72787278
hash_text[k] = 0;
72797279
}
72807280

7281+
cite_xptr = 0;
72817282
hash_used = hash_max + 1;
72827283
pool_ptr = 0;
72837284
str_ptr = 1;

tests/bibtex.rs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,18 @@ impl TestCase {
8585
}
8686

8787
#[test]
88-
fn single_entry() {
89-
TestCase::new("single_entry", None).go()
88+
fn test_single_entry() {
89+
TestCase::new("single_entry", Some("cites")).go()
90+
}
91+
92+
#[test]
93+
fn test_many() {
94+
TestCase::new("many", Some("cites")).go();
9095
}
9196

9297
#[test]
9398
fn test_empty_files() {
94-
TestCase::new("empty", Some("empty")).test_bbl(false).go()
99+
TestCase::new("empty", None).test_bbl(false).go()
95100
}
96101

97102
#[test]
@@ -107,3 +112,41 @@ fn test_mismatched_expr() {
107112
.test_bbl(false)
108113
.go();
109114
}
115+
116+
#[test]
117+
fn test_mismatched_data() {
118+
TestCase::new("data", Some("mismatched_braces"))
119+
.test_bbl(false)
120+
.go();
121+
}
122+
123+
#[test]
124+
fn test_mismatched_style() {
125+
TestCase::new("style", Some("mismatched_braces"))
126+
.test_bbl(false)
127+
.go();
128+
}
129+
130+
#[test]
131+
fn test_duplicated_data() {
132+
TestCase::new("data", Some("duplicated"))
133+
.test_bbl(false)
134+
.go();
135+
}
136+
137+
#[test]
138+
fn test_duplicated_style() {
139+
TestCase::new("style", Some("duplicated"))
140+
.test_bbl(false)
141+
.go();
142+
}
143+
144+
#[test]
145+
fn test_bad_crossref() {
146+
TestCase::new("bad", Some("crossref")).go();
147+
}
148+
149+
#[test]
150+
fn test_min_crossref() {
151+
TestCase::new("min", Some("crossref")).go();
152+
}

tests/bibtex/cites/many.aux

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
\relax
2+
\citation{Nobody01}
3+
\citation{Nobody02}
4+
\citation{Nobody03}
5+
\citation{Nobody04}
6+
\bibdata{many}
7+
\bibcite{Nobody01}{1}
8+
\bibcite{Nobody02}{2}
9+
\bibcite{Nobody03}{3}
10+
\bibcite{Nobody04}{4}
11+
\bibstyle{../plain}

tests/bibtex/cites/many.bbl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
\begin{thebibliography}{1}
2+
3+
\bibitem{Nobody03}
4+
5+
6+
\bibitem{Nobody04}
7+
8+
9+
\bibitem{Nobody01}
10+
Nobody Jr, Nobody Sr, and Nobody von Nobody.
11+
\newblock My article.
12+
\newblock {\em NoJournal}, 1(1):1--2, 2006.
13+
14+
\bibitem{Nobody02}
15+
Nobody Nobody.
16+
\newblock {\em My Book}.
17+
\newblock NothingCorp, 123 Example Street, Nowhere USA, 2023.
18+
19+
\end{thebibliography}

tests/bibtex/cites/many.bib

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@article{ Nobody01,
2+
author = "Nobody Jr and Nobody Sr and Nobody von Nobody",
3+
title = "My Article",
4+
year = "2006",
5+
journal = "NoJournal",
6+
volume = "1",
7+
number = "1",
8+
pages = "1--2",
9+
}
10+
11+
@book{ Nobody02,
12+
author = "Nobody, Nobody",
13+
title = "My Book",
14+
year = "2023",
15+
publisher = "NothingCorp",
16+
address = "123 Example Street, Nowhere USA",
17+
}
18+
19+
@misc { Nobody03 }
20+
21+
@misc { Nobody04 }
22+

tests/bibtex/cites/many.blg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This is BibTeX, Version 0.99d
2+
Capacity: max_strings=35307, hash_size=35307, hash_prime=30011
3+
The top-level auxiliary file: many.aux
4+
The style file: ../plain.bst
5+
Database file #1: many.bib
6+
Warning--to sort, need author or key in Nobody03
7+
Warning--to sort, need author or key in Nobody04
8+
(There were 2 warnings)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
\citation{Nobody06}
33
\bibdata{single_entry}
44
\bibcite{Nobody06}{1}
5-
\bibstyle{plain}
5+
\bibstyle{../plain}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
This is BibTeX, Version 0.99d
22
Capacity: max_strings=35307, hash_size=35307, hash_prime=30011
33
The top-level auxiliary file: single_entry.aux
4-
The style file: plain.bst
4+
The style file: ../plain.bst
55
Database file #1: single_entry.bib

0 commit comments

Comments
 (0)