SPB Git

Repository Public

OtherStylesTests.swift 27.7 KB 271 lines swift

1// ORIX Docs2// File: Packages/ORIXDocsKit/Tests/DocReferencesTests/OtherStylesTests.swift3// Description: Chicago 17 author-date, IEEE, MLA 9 and Vancouver formatting checked against the examples of the published guides.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import Foundation8import Testing9import DocModel10@testable import DocReferences1112/// Expected strings: The Chicago Manual of Style Online, "Author-Date: Sample Citations" (17th edition page,13/// https://www.chicagomanualofstyle.org/tools_citationguide/citation-guide-2.html, archived copies 2018–2024; the live page now shows14/// the 18th edition). The guide italicises the full stop after an italic title; the engine keeps terminal punctuation roman.15@Suite struct ChicagoStyleTests {16    static let grazer = BibEntry(key: "grazer2015", type: "book", authors: [person("Grazer", "Brian"), person("Fishman", "Charles")], year: 2015,17        fields: ["title": "A Curious Mind: The Secret to a Bigger Life", "publisher": "Simon & Schuster", "publisher-place": "New York"])18    static let smith = BibEntry(key: "smith2016", type: "book", authors: [person("Smith", "Zadie")], year: 2016,19        fields: ["title": "Swing Time", "publisher": "Penguin Press", "publisher-place": "New York"])20    static let thoreau = BibEntry(key: "thoreau2016", type: "chapter", authors: [person("Thoreau", "Henry David")], editors: [person("D’Agata", "John")], year: 2016,21        fields: ["title": "Walking", "container-title": "The Making of the American Essay", "page": "167–95", "publisher": "Graywolf Press", "publisher-place": "Minneapolis"])22    static let keng = BibEntry(key: "keng2017", type: "article-journal",23        authors: [person("Keng", "Shao-Hsun"), person("Lin", "Chun-Hung"), person("Orazem", "Peter F.")], year: 2017,24        fields: ["title": "Expanding College Access in Taiwan, 1978–2014: Effects on Graduate Quality and Income Inequality", "container-title": "Journal of Human Capital",25                 "volume": "11", "issue": "1", "season": "Spring", "page": "1–34", "DOI": "10.1086/690235"])26    static let bay = BibEntry(key: "bay2017", type: "article-journal",27        authors: [person("Bay", "Rachael A."), person("Rose", "Noah"), person("Barrett", "Rowan"), person("Bernatchez", "Louis"), person("Ghalambor", "Cameron K."),28                  person("Lasky", "Jesse R."), person("Brem", "Rachel B."), person("Palumbi", "Stephen R."), person("Ralph", "Peter")], year: 2017, month: 5,29        fields: ["title": "Predicting Responses to Contemporary Environmental Change Using Evolutionary Response Architectures", "container-title": "American Naturalist",30                 "volume": "189", "issue": "5", "page": "463–73", "DOI": "10.1086/691233"])31    static let yale = BibEntry(key: "yale", type: "webpage", authors: [org("Yale University")],32        fields: ["title": "About Yale: Yale Facts", "accessed": "2017-05-01", "URL": "https://www.yale.edu/about-yale/yale-facts"])3334    @Test func books() {35        #expect(formatted("chicago-author-date", Self.grazer) == "Grazer, Brian, and Charles Fishman. 2015. *A Curious Mind: The Secret to a Bigger Life*. New York: Simon & Schuster.")36        #expect(formatted("chicago-author-date", Self.smith) == "Smith, Zadie. 2016. *Swing Time*. New York: Penguin Press.")37    }3839    @Test func chapterEditedBookAndTranslation() {40        #expect(formatted("chicago-author-date", Self.thoreau) == "Thoreau, Henry David. 2016. “Walking.” In *The Making of the American Essay*, edited by John D’Agata, 167–95. Minneapolis: Graywolf Press.")41        let dagata = BibEntry(key: "dagata2016", type: "book", editors: [person("D’Agata", "John")], year: 2016,42            fields: ["title": "The Making of the American Essay", "publisher": "Graywolf Press", "publisher-place": "Minneapolis"])43        #expect(formatted("chicago-author-date", dagata) == "D’Agata, John, ed. 2016. *The Making of the American Essay*. Minneapolis: Graywolf Press.")44        let lahiri = BibEntry(key: "lahiri2016", type: "book", authors: [person("Lahiri", "Jhumpa")], year: 2016,45            fields: ["title": "In Other Words", "translator": "Goldstein, Ann", "publisher": "Alfred A. Knopf", "publisher-place": "New York"])46        #expect(formatted("chicago-author-date", lahiri) == "Lahiri, Jhumpa. 2016. *In Other Words*. Translated by Ann Goldstein. New York: Alfred A. Knopf.")47    }4849    @Test func journalArticles() {50        #expect(formatted("chicago-author-date", Self.keng) == "Keng, Shao-Hsun, Chun-Hung Lin, and Peter F. Orazem. 2017. “Expanding College Access in Taiwan, 1978–2014: Effects on Graduate Quality and Income Inequality.” *Journal of Human Capital* 11, no. 1 (Spring): 1–34. https://doi.org/10.1086/690235.")51        let lasalle = BibEntry(key: "lasalle2017", type: "article-journal", authors: [person("LaSalle", "Peter")], year: 2017,52            fields: ["title": "Conundrum: A Story about Reading", "container-title": "New England Review", "volume": "38", "issue": "1", "page": "95–109", "archive": "Project MUSE"])53        #expect(formatted("chicago-author-date", lasalle) == "LaSalle, Peter. 2017. “Conundrum: A Story about Reading.” *New England Review* 38 (1): 95–109. Project MUSE.")54        let satterfield = BibEntry(key: "satterfield2016", type: "article-journal", authors: [person("Satterfield", "Susan")], year: 2016, month: 4,55            fields: ["title": "Livy and the <i>Pax Deum</i>", "container-title": "Classical Philology", "volume": "111", "issue": "2", "page": "165–76"])56        #expect(formatted("chicago-author-date", satterfield) == "Satterfield, Susan. 2016. “Livy and the *Pax Deum*.” *Classical Philology* 111, no. 2 (April): 165–76.")57        #expect(formatted("chicago-author-date", Self.bay) == "Bay, Rachael A., Noah Rose, Rowan Barrett, Louis Bernatchez, Cameron K. Ghalambor, Jesse R. Lasky, Rachel B. Brem, Stephen R. Palumbi, and Peter Ralph. 2017. “Predicting Responses to Contemporary Environmental Change Using Evolutionary Response Architectures.” *American Naturalist* 189, no. 5 (May): 463–73. https://doi.org/10.1086/691233.")58    }5960    @Test func thesisNewsAndWebsites() {61        let rutz = BibEntry(key: "rutz2013", type: "thesis", authors: [person("Rutz", "Cynthia Lillian")], year: 2013,62            fields: ["title": "<i>King Lear</i> and Its Folktale Analogues", "genre": "PhD thesis", "publisher": "University of Chicago"])63        #expect(formatted("chicago-author-date", rutz) == "Rutz, Cynthia Lillian. 2013. “*King Lear* and Its Folktale Analogues.” PhD diss., University of Chicago.")64        let manjoo = BibEntry(key: "manjoo2017", type: "article-newspaper", authors: [person("Manjoo", "Farhad")], year: 2017, month: 3, day: 8,65            fields: ["title": "Snap Makes a Bet on the Cultural Supremacy of the Camera", "container-title": "New York Times",66                     "URL": "https://www.nytimes.com/2017/03/08/technology/snap-makes-a-bet-on-the-cultural-supremacy-of-the-camera.html"])67        #expect(formatted("chicago-author-date", manjoo) == "Manjoo, Farhad. 2017. “Snap Makes a Bet on the Cultural Supremacy of the Camera.” *New York Times*, March 8, 2017. https://www.nytimes.com/2017/03/08/technology/snap-makes-a-bet-on-the-cultural-supremacy-of-the-camera.html.")68        #expect(formatted("chicago-author-date", Self.yale) == "Yale University. n.d. “About Yale: Yale Facts.” Accessed May 1, 2017. https://www.yale.edu/about-yale/yale-facts.")69    }7071    @Test func websiteWithRevisionDateIsAKnownDeviation() {72        let google = BibEntry(key: "google2017", type: "webpage", authors: [org("Google")], year: 2017, month: 4, day: 17,73            fields: ["title": "Privacy Policy", "container-title": "Privacy & Terms", "URL": "https://www.google.com/policies/privacy/"])74        expectKnownDeviation(formatted("chicago-author-date", google),75            published: "Google. 2017. “Privacy Policy.” Privacy & Terms. Last modified April 17, 2017. https://www.google.com/policies/privacy/.",76            ours: "Google. 2017. “Privacy Policy.” Privacy & Terms. https://www.google.com/policies/privacy/.",77            "the model cannot tell a publication date from a revision date, so no “Last modified” statement is produced")78    }7980    @Test func inTextCitations() {81        // In-text forms printed under each example of the guide.82        let c = Cited(style: "chicago-author-date", entries: [Self.grazer, Self.smith, Self.thoreau, Self.keng, Self.bay, Self.yale],83                      citations: [[cite("grazer2015")], [cite("smith2016")], [cite("thoreau2016")], [cite("keng2017")], [cite("bay2017")], [cite("yale")]])84        #expect(c.text(cite("grazer2015", "12")) == "(Grazer and Fishman 2015, 12)")85        #expect(c.text(cite("smith2016", "315–16")) == "(Smith 2016, 315–16)")86        #expect(c.text(cite("thoreau2016", "177-78")) == "(Thoreau 2016, 177–78)")87        #expect(c.text(cite("keng2017", "9–10")) == "(Keng, Lin, and Orazem 2017, 9–10)")88        #expect(c.text(cite("bay2017", "465")) == "(Bay et al. 2017, 465)")89        #expect(c.text(cite("yale")) == "(Yale University, n.d.)")90        #expect(c.text(cite("smith2016"), cite("grazer2015")) == "(Smith 2016; Grazer and Fishman 2015)")91    }92}9394/// Expected strings: IEEE Reference Guide (IEEE Author Center), version of 2023/2025 unless noted. Italics follow the guide's rule95/// (book and periodical titles); the characters are the guide's.96@Suite struct IEEEStyleTests {97    @Test func books() {98        let klaus = BibEntry(key: "klaus1986", type: "book", authors: [person("Klaus", "B."), person("Horn", "P.")], year: 1986,99            fields: ["title": "Robot Vision", "publisher": "MIT Press", "publisher-place": "Cambridge, MA, USA"])100        #expect(formatted("ieee", klaus) == "B. Klaus and P. Horn, *Robot Vision*. Cambridge, MA, USA: MIT Press, 1986.")101    }102103    @Test func chaptersInBooks() {104        let stein = BibEntry(key: "stein1994", type: "chapter", authors: [person("Stein", "L.")], editors: [person("Brake", "J. S.")], year: 1994,105            fields: ["title": "Random patterns", "container-title": "Computers and You", "publisher": "Wiley", "publisher-place": "New York, NY, USA", "page": "55–70"])106        #expect(formatted("ieee", stein) == "L. Stein, “Random patterns,” in *Computers and You*, J. S. Brake, Ed., New York, NY, USA: Wiley, 1994, pp. 55–70.")107        let young = BibEntry(key: "young1964", type: "chapter", authors: [person("Young", "G. O.")], editors: [person("Peters", "J.")], year: 1964,108            fields: ["title": "Synthetic structure of industrial plastics", "container-title": "Plastics, vol. 3, Polymers of Hexadromicon", "edition": "2",109                     "publisher": "McGraw-Hill", "publisher-place": "New York, NY, USA", "page": "15–64", "URL": "https://www.scirp.org"])110        #expect(formatted("ieee", young) == "G. O. Young, “Synthetic structure of industrial plastics,” in *Plastics, vol. 3, Polymers of Hexadromicon*, J. Peters, Ed., 2nd ed. New York, NY, USA: McGraw-Hill, 1964, pp. 15–64. [Online]. Available: https://www.scirp.org")111    }112113    @Test func periodicals() {114        let chiampi = BibEntry(key: "chiampi2011", type: "article-journal", authors: [person("Chiampi", "M. M."), person("Zilberti", "L. L.")], year: 2011, month: 10,115            fields: ["title": "Induction of electric field in human bodies moving near MRI: An efficient BEM computational procedure",116                     "container-title": "IEEE Transactions on Biomedical Engineering", "container-title-short": "IEEE Trans. Biomed. Eng.",117                     "volume": "58", "issue": "10", "page": "2787-2793", "DOI": "10.1109/TBME.2011.2158315"])118        #expect(formatted("ieee", chiampi) == "M. M. Chiampi and L. L. Zilberti, “Induction of electric field in human bodies moving near MRI: An efficient BEM computational procedure,” *IEEE Trans. Biomed. Eng.*, vol. 58, no. 10, pp. 2787–2793, Oct. 2011, doi: 10.1109/TBME.2011.2158315.")119        let risk = BibEntry(key: "risk1986", type: "article-journal", authors: [person("Risk", "W. P."), person("Kino", "G. S."), person("Shaw", "H. J.")], year: 1986, month: 2,120            fields: ["title": "Fiber-optic frequency shifter using a surface acoustic wave incident at an oblique angle", "container-title": "Opt. Lett.",121                     "volume": "11", "issue": "2", "page": "115–117", "URL": "http://ol.osa.org/abstract.cfm?URI=ol-11-2-115"])122        #expect(formatted("ieee", risk) == "W. P. Risk, G. S. Kino, and H. J. Shaw, “Fiber-optic frequency shifter using a surface acoustic wave incident at an oblique angle,” *Opt. Lett.*, vol. 11, no. 2, pp. 115–117, Feb. 1986. [Online]. Available: http://ol.osa.org/abstract.cfm?URI=ol-11-2-115")123    }124125    @Test func conferenceThesesAndReport() {126        let bingulac = BibEntry(key: "bingulac1994", type: "paper-conference", authors: [person("Bingulac", "S. P.")], year: 1994,127            fields: ["title": "On the compatibility of adaptive controllers", "container-title": "Proc. 4th Annu. Allerton Conf. Circuit Syst. Theory",128                     "publisher-place": "New York, NY, USA", "page": "8–16"])129        #expect(formatted("ieee", bingulac) == "S. P. Bingulac, “On the compatibility of adaptive controllers,” in *Proc. 4th Annu. Allerton Conf. Circuit Syst. Theory*, New York, NY, USA, 1994, pp. 8–16.")130        let williams = BibEntry(key: "williams1993", type: "thesis", authors: [person("Williams", "J. O.")], year: 1993,131            fields: ["title": "Narrow-band analyzer", "genre": "PhD thesis", "publisher": "Dept. Elect. Eng., Harvard Univ.", "publisher-place": "Cambridge, MA, USA"])132        #expect(formatted("ieee", williams) == "J. O. Williams, “Narrow-band analyzer,” Ph.D. dissertation, Dept. Elect. Eng., Harvard Univ., Cambridge, MA, USA, 1993.")133        let kawasaki = BibEntry(key: "kawasaki1993", type: "thesis", authors: [person("Kawasaki", "N.")], year: 1993,134            fields: ["title": "Parametric study of thermal and chemical nonequilibrium nozzle flow", "genre": "Master's thesis",135                     "publisher": "Dept. Electron. Eng., Osaka Univ.", "publisher-place": "Osaka, Japan"])136        #expect(formatted("ieee", kawasaki) == "N. Kawasaki, “Parametric study of thermal and chemical nonequilibrium nozzle flow,” M.S. thesis, Dept. Electron. Eng., Osaka Univ., Osaka, Japan, 1993.")137        let reber = BibEntry(key: "reber1988", type: "report", authors: [person("Reber", "E. E."), person("Michell", "R. L."), person("Carter", "C. J.")], year: 1988, month: 11,138            fields: ["title": "Oxygen absorption in the earth’s atmosphere", "publisher": "Aerospace Corp.", "publisher-place": "Los Angeles, CA, USA",139                     "genre": "Technical report", "number": "TR-0200 (4230-46)-3"])140        expectKnownDeviation(formatted("ieee", reber),141            published: "E. E. Reber, R. L. Michell, and C. J. Carter, “Oxygen absorption in the earth’s atmosphere,” Aerospace Corp., Los Angeles, CA, USA,Tech. Rep. TR-0200 (4230-46)-3, Nov. 1988.",142            ours: "E. E. Reber, R. L. Michell, and C. J. Carter, “Oxygen absorption in the earth’s atmosphere,” Aerospace Corp., Los Angeles, CA, USA, Tech. Rep. TR-0200 (4230-46)-3, Nov. 1988.",143            "the guide prints “USA,Tech. Rep.” without a space (a typo in every version of the guide); the engine writes the space")144    }145146    @Test func website() {147        // Guide versions 2023 and 2025 (the 2018 version used "URL (accessed Feb. 1, 2009)."). The guide's URL contains a stray space.148        let smith = BibEntry(key: "smith2009", type: "webpage", authors: [person("Smith", "J.")],149            fields: ["title": "Obama inaugurated as President", "container-title": "CNN.com", "accessed": "2009-02-01",150                     "URL": "http://www.cnn.com/POLITICS/01/21/obama_inaugurated/index.html"])151        #expect(formatted("ieee", smith) == "J. Smith. “Obama inaugurated as President.” CNN.com. Accessed: Feb. 1, 2009. [Online.] Available: http://www.cnn.com/POLITICS/01/21/obama_inaugurated/index.html")152    }153154    @Test func moreThanSixAuthorsAndNumberLabel() {155        // Guide: "list names of all authors, up to six names. If there are more than six names listed, use the primary author's name followed by et al."156        let seven = BibEntry(key: "seven", type: "article-journal", authors: (1...7).map { person("Author\($0)", "A.") }, year: 2020,157            fields: ["title": "T", "container-title": "J", "volume": "1", "page": "5"])158        #expect(formatted("ieee", seven) == "A. Author1 et al., “T,” *J*, vol. 1, p. 5, 2020.")159        var six = seven; six.authors.removeLast()160        #expect(formatted("ieee", six).hasPrefix("A. Author1, A. Author2, A. Author3, A. Author4, A. Author5, and A. Author6, “T,”"))161        #expect(marked(CitationEngine(styleID: "ieee").formattedEntry(seven, number: 3)).hasPrefix("[3]\tA. Author1 et al."))162    }163}164165/// Expected strings: MLA Style Center, "Works Cited: Citations by Format" (https://style.mla.org/works-cited/citations-by-format/…).166/// The site prints page ranges with a hyphen and URLs without "https://"; the engine prints both as stored.167@Suite struct MLAStyleTests {168    static let mantel = BibEntry(key: "mantel2010", type: "book", authors: [person("Mantel", "Hilary")], year: 2010, fields: ["title": "Wolf Hall", "publisher": "Picador"])169170    @Test func books() {171        // …/citations-by-format/books/172        #expect(formatted("mla", Self.mantel) == "Mantel, Hilary. *Wolf Hall*. Picador, 2010.")173        let sanchez = BibEntry(key: "sanchez2018", type: "book", editors: [person("Sánchez Prado", "Ignacio M.")], year: 2018,174            fields: ["title": "Mexican Literature in Theory", "publisher": "Bloomsbury"])175        #expect(formatted("mla", sanchez) == "Sánchez Prado, Ignacio M., editor. *Mexican Literature in Theory*. Bloomsbury, 2018.")176        let beowulf = BibEntry(key: "beowulf2004", type: "book", editors: [person("Anderson", "Sarah")], year: 2004,177            fields: ["title": "Beowulf", "translator": "Sullivan, Alan and Murphy, Timothy", "publisher": "Pearson"])178        #expect(formatted("mla", beowulf) == "*Beowulf*. Translated by Alan Sullivan and Timothy Murphy, edited by Sarah Anderson, Pearson, 2004.")179    }180181    @Test func onlineWorks() {182        // …/citations-by-format/online-works/183        let goldman = BibEntry(key: "goldman2010", type: "article-journal", authors: [person("Goldman", "Anne")], year: 2010,184            fields: ["title": "Questions of Transport: Reading Primo Levi Reading Dante", "container-title": "The Georgia Review", "volume": "64", "issue": "1",185                     "season": "spring", "page": "69-88", "archive": "JSTOR", "URL": "www.jstor.org/stable/41403188"])186        #expect(formatted("mla", goldman) == "Goldman, Anne. “Questions of Transport: Reading Primo Levi Reading Dante.” *The Georgia Review*, vol. 64, no. 1, spring 2010, pp. 69-88. *JSTOR*, www.jstor.org/stable/41403188.")187        let poe = BibEntry(key: "poe1902", type: "chapter", authors: [person("Poe", "Edgar Allan")], editors: [person("Harrison", "James A.")], year: 1902,188            fields: ["title": "The Masque of the Red Death", "container-title": "The Complete Works of Edgar Allan Poe", "volume": "4", "publisher": "Thomas Y. Crowell",189                     "page": "250-58", "archive": "HathiTrust Digital Library", "URL": "hdl.handle.net/2027/coo.31924079574368"])190        #expect(formatted("mla", poe) == "Poe, Edgar Allan. “The Masque of the Red Death.” *The Complete Works of Edgar Allan Poe*, edited by James A. Harrison, vol. 4, Thomas Y. Crowell, 1902, pp. 250-58. *HathiTrust Digital Library*, hdl.handle.net/2027/coo.31924079574368.")191        // The page prints this URL with a stray space and "thecreative"; the URL below is the same address written correctly.192        let deresiewicz = BibEntry(key: "deresiewicz2014", type: "article-magazine", authors: [person("Deresiewicz", "William")], year: 2014, month: 12, day: 28,193            fields: ["title": "The Death of the Artist—and the Birth of the Creative Entrepreneur", "container-title": "The Atlantic",194                     "URL": "theatlantic.com/magazine/archive/2015/01/the-death-of-the-artist-and-the-birth-of-the-creative-entrepreneur/383497/"])195        #expect(formatted("mla", deresiewicz) == "Deresiewicz, William. “The Death of the Artist—and the Birth of the Creative Entrepreneur.” *The Atlantic*, 28 Dec. 2014, theatlantic.com/magazine/archive/2015/01/the-death-of-the-artist-and-the-birth-of-the-creative-entrepreneur/383497/.")196    }197198    @Test func authorRulesAndInText() {199        // MLA Handbook, 9th ed., rules (5.7–5.8, 6.3–6.5), asserted as rules: two authors are joined with "and", three or more use "et al.";200        // the in-text citation is author and page with no comma; two works by one author add a short title.201        let dorris = BibEntry(key: "dorris1999", type: "book", authors: [person("Dorris", "Michael"), person("Erdrich", "Louise")], year: 1999,202            fields: ["title": "The Crown of Columbus", "publisher": "HarperCollins Publishers"])203        #expect(formatted("mla", dorris) == "Dorris, Michael, and Louise Erdrich. *The Crown of Columbus*. HarperCollins Publishers, 1999.")204        let burdick = BibEntry(key: "burdick2012", type: "book",205            authors: [person("Burdick", "Anne"), person("Drucker", "Johanna"), person("Lunenfeld", "Peter"), person("Presner", "Todd"), person("Schnapp", "Jeffrey")],206            year: 2012, fields: ["title": "Digital_Humanities", "publisher": "MIT P"])207        #expect(formatted("mla", burdick) == "Burdick, Anne, et al. *Digital_Humanities*. MIT P, 2012.")208        let mantel2 = BibEntry(key: "mantel2012", type: "book", authors: [person("Mantel", "Hilary")], year: 2012, fields: ["title": "Bring Up the Bodies", "publisher": "Picador"])209        let c = Cited(style: "mla", entries: [dorris, burdick, Self.mantel, mantel2], citations: [[cite("dorris1999"), cite("burdick2012"), cite("mantel2010"), cite("mantel2012")]])210        #expect(c.text(cite("dorris1999", "23")) == "(Dorris and Erdrich 23)")211        #expect(c.text(cite("burdick2012", "42")) == "(Burdick et al. 42)")212        #expect(c.text(cite("mantel2010", "101")) == "(Mantel, Wolf Hall 101)")213        #expect(c.text(cite("mantel2010", "101", suppressAuthor: true)) == "(Wolf Hall 101)")214        #expect(c.text(cite("dorris1999", "23", suppressAuthor: true)) == "(23)")215        // Works cited: alphabetical by author, then by title.216        #expect(c.bibliography.map { String($0.prefix(18)) } == ["Burdick, Anne, et ", "Dorris, Michael, a", "Mantel, Hilary. *B", "Mantel, Hilary. *W"])217    }218}219220/// Expected strings: U.S. National Library of Medicine, "Samples of Formatted References for Authors of Journal Articles"221/// (https://www.nlm.nih.gov/bsd/uniform_requirements.html), the ICMJE recommended format.222@Suite struct VancouverStyleTests {223    @Test func journalArticles() {224        let halpern = BibEntry(key: "halpern2002", type: "article-journal", authors: [person("Halpern", "Scott D."), person("Ubel", "Peter A."), person("Caplan", "Arthur L.")],225            year: 2002, month: 7, day: 25,226            fields: ["title": "Solid-organ transplantation in HIV-infected patients", "container-title": "The New England Journal of Medicine",227                     "container-title-short": "N Engl J Med", "volume": "347", "issue": "4", "page": "284–7"])228        #expect(formatted("vancouver", halpern) == "Halpern SD, Ubel PA, Caplan AL. Solid-organ transplantation in HIV-infected patients. N Engl J Med. 2002 Jul 25;347(4):284-7.")229        let rose = BibEntry(key: "rose2002", type: "article-journal",230            authors: [person("Rose", "M E"), person("Huerbin", "M B"), person("Melick", "J"), person("Marion", "D W"), person("Palmer", "A M"), person("Schiding", "J K"),231                      person("Kochanek", "P M"), person("Graham", "S H")], year: 2002,232            fields: ["title": "Regulation of interstitial excitatory amino acid concentrations after cortical contusion injury", "container-title": "Brain Res",233                     "volume": "935", "issue": "1-2", "page": "40-6"])234        #expect(formatted("vancouver", rose) == "Rose ME, Huerbin MB, Melick J, Marion DW, Palmer AM, Schiding JK, et al. Regulation of interstitial excitatory amino acid concentrations after cortical contusion injury. Brain Res. 2002;935(1-2):40-6.")235        let dpp = BibEntry(key: "dpp2002", type: "article-journal", authors: [org("Diabetes Prevention Program Research Group")], year: 2002,236            fields: ["title": "Hypertension, insulin, and proinsulin in participants with impaired glucose tolerance", "container-title": "Hypertension",237                     "volume": "40", "issue": "5", "page": "679-86"])238        #expect(formatted("vancouver", dpp) == "Diabetes Prevention Program Research Group. Hypertension, insulin, and proinsulin in participants with impaired glucose tolerance. Hypertension. 2002;40(5):679-86.")239    }240241    @Test func booksChapterAndDissertation() {242        let murray = BibEntry(key: "murray2002", type: "book",243            authors: [person("Murray", "P R"), person("Rosenthal", "K S"), person("Kobayashi", "G S"), person("Pfaller", "M A")], year: 2002,244            fields: ["title": "Medical microbiology", "edition": "4", "publisher": "Mosby", "publisher-place": "St. Louis"])245        #expect(formatted("vancouver", murray) == "Murray PR, Rosenthal KS, Kobayashi GS, Pfaller MA. Medical microbiology. 4th ed. St. Louis: Mosby; 2002.")246        let gilstrap = BibEntry(key: "gilstrap2002", type: "book",247            editors: [person("Gilstrap", "L C, 3rd"), person("Cunningham", "F G"), person("VanDorsten", "J P")], year: 2002,248            fields: ["title": "Operative obstetrics", "edition": "2nd", "publisher": "McGraw-Hill", "publisher-place": "New York"])249        #expect(formatted("vancouver", gilstrap) == "Gilstrap LC 3rd, Cunningham FG, VanDorsten JP, editors. Operative obstetrics. 2nd ed. New York: McGraw-Hill; 2002.")250        let meltzer = BibEntry(key: "meltzer2002", type: "chapter", authors: [person("Meltzer", "P S"), person("Kallioniemi", "A"), person("Trent", "J M")],251            editors: [person("Vogelstein", "B"), person("Kinzler", "K W")], year: 2002,252            fields: ["title": "Chromosome alterations in human solid tumors", "container-title": "The genetic basis of human cancer", "publisher": "McGraw-Hill",253                     "publisher-place": "New York", "page": "93-113"])254        #expect(formatted("vancouver", meltzer) == "Meltzer PS, Kallioniemi A, Trent JM. Chromosome alterations in human solid tumors. In: Vogelstein B, Kinzler KW, editors. The genetic basis of human cancer. New York: McGraw-Hill; 2002. p. 93-113.")255        let borkowski = BibEntry(key: "borkowski2002", type: "thesis", authors: [person("Borkowski", "M M")], year: 2002,256            fields: ["title": "Infant sleep and feeding: a telephone survey of Hispanic Americans", "genre": "PhD thesis", "publisher": "Central Michigan University",257                     "publisher-place": "Mount Pleasant (MI)"])258        #expect(formatted("vancouver", borkowski) == "Borkowski MM. Infant sleep and feeding: a telephone survey of Hispanic Americans [dissertation]. Mount Pleasant (MI): Central Michigan University; 2002.")259    }260261    @Test func websiteIsAKnownDeviation() {262        let eatright = BibEntry(key: "eatright", type: "webpage", year: 2016,263            fields: ["title": "eatright.org", "publisher": "Academy of Nutrition and Dietetics", "publisher-place": "Chicago", "accessed": "2016-12-27",264                     "URL": "https://www.eatright.org/"])265        expectKnownDeviation(formatted("vancouver", eatright),266            published: "eatright.org [Internet]. Chicago: Academy of Nutrition and Dietetics; c2016 [cited 2016 Dec 27]. Available from: https://www.eatright.org/.",267            ours: "eatright.org [Internet]. Chicago: Academy of Nutrition and Dietetics; 2016 [cited 2016 Dec 27]. Available from: https://www.eatright.org/.",268            "a copyright date (“c2016”) cannot be told from a publication date in the model")269    }270}271
Files main
Menu

Theme