@@ -424,3 +424,109 @@ Test mixed UTF-8 with BibTeX special characters and escapes
424424 NOTE = "Special: \&, \%, $, plus UTF-8: café, résumé, naïve, piñata" ,
425425 PUBLISHER = "Éditions Académiques & Co."
426426 }
427+
428+ Test duplicate citekey detection with case- insensitive comparison in strict mode
429+ $ cat > duplicates.bib << EOF
430+ > @ article{test1,
431+ > title = "First Article" ,
432+ > author = "John Doe" ,
433+ > year = 2020
434+ > }
435+ >
436+ > @ book{Test1,
437+ > title = "Same Citekey Different Case" ,
438+ > author = "Jane Smith" ,
439+ > year = 2021
440+ > }
441+ >
442+ > @ inproceedings{test2,
443+ > title = "Different Citekey" ,
444+ > author = "Bob Wilson" ,
445+ > year = 2022
446+ > }
447+ > EOF
448+
449+ $ bibfmt -- strict - f duplicates.bib
450+ Warning: Duplicate citekeys found (case- insensitive): test1
451+ @ article{test1,
452+ TITLE = "First Article" ,
453+ AUTHOR = "John Doe" ,
454+ YEAR = 2020
455+ }
456+
457+ @ book{Test1,
458+ TITLE = "Same Citekey Different Case" ,
459+ AUTHOR = "Jane Smith" ,
460+ YEAR = 2021
461+ }
462+
463+ @ inproceedings{test2,
464+ TITLE = "Different Citekey" ,
465+ AUTHOR = "Bob Wilson" ,
466+ YEAR = 2022
467+ }
468+
469+ Test that non- strict mode doesn't warn about duplicate citekeys
470+ $ bibfmt -f duplicates.bib
471+ @article{test1,
472+ TITLE = "First Article",
473+ AUTHOR = "John Doe",
474+ YEAR = 2020
475+ }
476+
477+ @book{Test1,
478+ TITLE = "Same Citekey Different Case",
479+ AUTHOR = "Jane Smith",
480+ YEAR = 2021
481+ }
482+
483+ @inproceedings{test2,
484+ TITLE = "Different Citekey",
485+ AUTHOR = "Bob Wilson",
486+ YEAR = 2022
487+ }
488+
489+ Test multiple duplicate citekeys in strict mode
490+ $ cat > multiple_duplicates.bib << EOF
491+ > @article{paper1,
492+ > title = "First Paper",
493+ > author = "Author One"
494+ > }
495+ >
496+ > @book{PAPER1,
497+ > title = "Book Version",
498+ > author = "Author Two"
499+ > }
500+ >
501+ > @inproceedings{conference1,
502+ > title = "Conference Paper",
503+ > author = "Author Three"
504+ > }
505+ >
506+ > @misc{Conference1,
507+ > title = "Same Conference Different Type",
508+ > author = "Author Four"
509+ > }
510+ > EOF
511+
512+ $ bibfmt --strict -f multiple_duplicates.bib
513+ Warning: Duplicate citekeys found (case-insensitive): conference1, paper1
514+ @article{paper1,
515+ TITLE = "First Paper",
516+ AUTHOR = "Author One"
517+ }
518+
519+ @book{PAPER1,
520+ TITLE = "Book Version",
521+ AUTHOR = "Author Two"
522+ }
523+
524+ @inproceedings{conference1,
525+ TITLE = "Conference Paper",
526+ AUTHOR = "Author Three"
527+ }
528+
529+ @misc{Conference1,
530+ TITLE = "Same Conference Different Type",
531+ AUTHOR = "Author Four"
532+ }
0 commit comments