Skip to content

Commit 74e99e4

Browse files
committed
Add a bunch more tests - crossrefs, multiple cites, mismatched aux lines. This should cover most main code paths as well as some particularly useful warning/error paths
1 parent b8b0245 commit 74e99e4

36 files changed

Lines changed: 276 additions & 11 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: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ 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"))
95+
.go();
9096
}
9197

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

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)